Skip to content

Commit e4a7420

Browse files
committed
docs(App): Adds documentation for the App class
1 parent 02c9df1 commit e4a7420

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

src/app.ts

+51-1
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,33 @@ import moment = require('moment');
88
import chrono = require('chrono-node');
99
import { displayNumber, displayText } from './display.helper';
1010

11-
11+
/**
12+
* The main app class
13+
*/
1214
export class App {
1315

16+
/**
17+
* The api object used to communicate with Jira
18+
*/
1419
api: JiraApi;
1520

21+
/**
22+
* The app's configuration
23+
*/
1624
config: Conf;
1725

26+
/**
27+
* The JiraService that abstracts the actual logic to load data from and interact with Jira
28+
*/
1829
service: JiraService;
1930

2031
constructor() {
2132

2233
}
2334

35+
/**
36+
* Initialize the application
37+
*/
2438
initialize(): Promise<App> {
2539
return this._loadConfig().then(() => {
2640
this._initializeApi();
@@ -29,6 +43,10 @@ export class App {
2943
});
3044
}
3145

46+
/**
47+
* Load the backlog of the given project and display it
48+
* @param project
49+
*/
3250
backlog(project: string) {
3351
this.service.getSprintsForProject(project).then(sprints => {
3452
return sprints.filter(sprint => sprint.state !== 'closed')
@@ -44,6 +62,11 @@ export class App {
4462
});
4563
}
4664

65+
/**
66+
* Load the board of the active sprint of the given project and display it
67+
* @param project
68+
* @param onlyMine
69+
*/
4770
board(project: string, onlyMine?: boolean) {
4871
this.service.getDisplayBoardForProject(project, onlyMine).then(board => {
4972
const maxWidth = (process.stdout.columns || 80) - board.length;
@@ -70,6 +93,11 @@ export class App {
7093
});
7194
}
7295

96+
/**
97+
* Load the work log of the given user for the given date ad display it
98+
* @param user
99+
* @param date
100+
*/
73101
worklog(user = 'me', date?: string) {
74102
const parsedDate = (date) ? moment(chrono.parseDate(date)) : moment();
75103
this.service.getWorklogsForUser(user, parsedDate).then(worklogs => {
@@ -105,12 +133,22 @@ export class App {
105133
});
106134
}
107135

136+
/**
137+
* Log a new work entry to the given issue
138+
* @param issue
139+
* @param duration
140+
* @param start
141+
* @param message
142+
*/
108143
log(issue: string, duration: number, start = new Date(), message?: string) {
109144
this.service.addWorkLogToIssue(issue, duration, start, message).then(response => {
110145
// do nothing
111146
});
112147
}
113148

149+
/**
150+
* Guide the user through the initial setup
151+
*/
114152
init(): Promise<string> {
115153
return inquirer.prompt([
116154
{
@@ -135,6 +173,10 @@ export class App {
135173
});
136174
}
137175

176+
/**
177+
* Load the config from the config dir and return it in a Promise
178+
* @private
179+
*/
138180
private _loadConfig(): Promise<Conf> {
139181
this.config = new Conf({
140182
encryptionKey: 'sdfyu7y3irfsov869wuvut7sdiyfuk'
@@ -147,10 +189,18 @@ export class App {
147189
}
148190
}
149191

192+
/**
193+
* Inititalize the JiraApi interface
194+
* @private
195+
*/
150196
private _initializeApi() {
151197
this.api = new JiraApi(this.config.get('api'));
152198
}
153199

200+
/**
201+
* Initialize the JiraService
202+
* @private
203+
*/
154204
private _initializeService() {
155205
this.service = new JiraService(this.api);
156206
}

0 commit comments

Comments
 (0)