@@ -20,7 +20,6 @@ import {AbstractComponent, ChildableComponent, Component, Option} from './utils/
20
20
import { Options , OptionsReadMode , IOptionsReadResult } from './utils/options/index' ;
21
21
import { ParameterType } from './utils/options/declaration' ;
22
22
23
-
24
23
/**
25
24
* The default TypeDoc main application class.
26
25
*
@@ -35,63 +34,60 @@ import {ParameterType} from './utils/options/declaration';
35
34
* and emit a series of events while processing the project. Subscribe to these Events
36
35
* to control the application flow or alter the output.
37
36
*/
38
- @Component ( { name :'application' , internal :true } )
39
- export class Application extends ChildableComponent < Application , AbstractComponent < Application > >
40
- {
41
- options :Options ;
37
+ @Component ( { name : 'application' , internal : true } )
38
+ export class Application extends ChildableComponent < Application , AbstractComponent < Application > > {
39
+ options : Options ;
42
40
43
41
/**
44
42
* The converter used to create the declaration reflections.
45
43
*/
46
- converter :Converter ;
44
+ converter : Converter ;
47
45
48
46
/**
49
47
* The renderer used to generate the documentation output.
50
48
*/
51
- renderer :Renderer ;
49
+ renderer : Renderer ;
52
50
53
51
/**
54
52
* The logger that should be used to output messages.
55
53
*/
56
- logger :Logger ;
54
+ logger : Logger ;
57
55
58
- plugins :PluginHost ;
56
+ plugins : PluginHost ;
59
57
60
58
@Option ( {
61
59
name : 'logger' ,
62
60
help : 'Specify the logger that should be used, \'none\' or \'console\'' ,
63
61
defaultValue : 'console' ,
64
62
type : ParameterType . Mixed
65
63
} )
66
- loggerType :string | Function ;
64
+ loggerType : string | Function ;
67
65
68
66
@Option ( {
69
67
name : 'ignoreCompilerErrors' ,
70
68
help : 'Should TypeDoc generate documentation pages even after the compiler has returned errors?' ,
71
69
type : ParameterType . Boolean
72
70
} )
73
- ignoreCompilerErrors :boolean ;
71
+ ignoreCompilerErrors : boolean ;
74
72
75
73
@Option ( {
76
74
name : 'exclude' ,
77
75
help : 'Define a pattern for excluded files when specifying paths.' ,
78
76
type : ParameterType . String
79
77
} )
80
- exclude :string ;
78
+ exclude : string ;
81
79
82
80
/**
83
81
* The version number of TypeDoc.
84
82
*/
85
83
static VERSION = '{{ VERSION }}' ;
86
84
87
-
88
-
89
85
/**
90
86
* Create a new TypeDoc application instance.
91
87
*
92
88
* @param options An object containing the options that should be used.
93
89
*/
94
- constructor ( options ?:Object ) {
90
+ constructor ( options ?: Object ) {
95
91
super ( null ) ;
96
92
97
93
this . logger = new ConsoleLogger ( ) ;
@@ -103,18 +99,17 @@ export class Application extends ChildableComponent<Application, AbstractCompone
103
99
this . bootstrap ( options ) ;
104
100
}
105
101
106
-
107
102
/**
108
103
* Initialize TypeDoc with the given options object.
109
104
*
110
105
* @param options The desired options to set.
111
106
*/
112
- protected bootstrap ( options ?:Object ) :IOptionsReadResult {
107
+ protected bootstrap ( options ?: Object ) : IOptionsReadResult {
113
108
this . options . read ( options , OptionsReadMode . Prefetch ) ;
114
109
115
110
const logger = this . loggerType ;
116
111
if ( typeof logger === 'function' ) {
117
- this . logger = new CallbackLogger ( < any > logger ) ;
112
+ this . logger = new CallbackLogger ( < any > logger ) ;
118
113
} else if ( logger === 'none' ) {
119
114
this . logger = new Logger ( ) ;
120
115
}
@@ -123,42 +118,37 @@ export class Application extends ChildableComponent<Application, AbstractCompone
123
118
return this . options . read ( options , OptionsReadMode . Fetch ) ;
124
119
}
125
120
126
-
127
121
/**
128
122
* Return the application / root component instance.
129
123
*/
130
- get application ( ) :Application {
124
+ get application ( ) : Application {
131
125
return this ;
132
126
}
133
127
134
-
135
- get isCLI ( ) :boolean {
128
+ get isCLI ( ) : boolean {
136
129
return false ;
137
130
}
138
131
139
-
140
132
/**
141
133
* Return the path to the TypeScript compiler.
142
134
*/
143
- public getTypeScriptPath ( ) :string {
135
+ public getTypeScriptPath ( ) : string {
144
136
return Path . dirname ( require . resolve ( 'typescript' ) ) ;
145
137
}
146
138
147
-
148
- public getTypeScriptVersion ( ) :string {
139
+ public getTypeScriptVersion ( ) : string {
149
140
const tsPath = this . getTypeScriptPath ( ) ;
150
141
const json = JSON . parse ( FS . readFileSync ( Path . join ( tsPath , '..' , 'package.json' ) , 'utf8' ) ) ;
151
142
return json . version ;
152
143
}
153
144
154
-
155
145
/**
156
146
* Run the converter for the given set of files and return the generated reflections.
157
147
*
158
148
* @param src A list of source that should be compiled and converted.
159
149
* @returns An instance of ProjectReflection on success, NULL otherwise.
160
150
*/
161
- public convert ( src :string [ ] ) :ProjectReflection {
151
+ public convert ( src : string [ ] ) : ProjectReflection {
162
152
this . logger . writeln ( 'Using TypeScript %s from %s' , this . getTypeScriptVersion ( ) , this . getTypeScriptPath ( ) ) ;
163
153
164
154
const result = this . converter . convert ( src ) ;
@@ -175,26 +165,27 @@ export class Application extends ChildableComponent<Application, AbstractCompone
175
165
}
176
166
}
177
167
178
-
179
168
/**
180
169
* @param src A list of source files whose documentation should be generated.
181
170
*/
182
- public generateDocs ( src :string [ ] , out :string ) :boolean ;
171
+ public generateDocs ( src : string [ ] , out : string ) : boolean ;
183
172
184
173
/**
185
174
* @param project The project the documentation should be generated for.
186
175
*/
187
- public generateDocs ( project :ProjectReflection , out :string ) :boolean ;
176
+ public generateDocs ( project : ProjectReflection , out : string ) : boolean ;
188
177
189
178
/**
190
179
* Run the documentation generator for the given set of files.
191
180
*
192
181
* @param out The path the documentation should be written to.
193
182
* @returns TRUE if the documentation could be generated successfully, otherwise FALSE.
194
183
*/
195
- public generateDocs ( input :any , out :string ) :boolean {
184
+ public generateDocs ( input : any , out : string ) : boolean {
196
185
const project = input instanceof ProjectReflection ? input : this . convert ( input ) ;
197
- if ( ! project ) return false ;
186
+ if ( ! project ) {
187
+ return false ;
188
+ }
198
189
199
190
out = Path . resolve ( out ) ;
200
191
this . renderer . render ( project , out ) ;
@@ -207,26 +198,27 @@ export class Application extends ChildableComponent<Application, AbstractCompone
207
198
return true ;
208
199
}
209
200
210
-
211
201
/**
212
202
* @param src A list of source that should be compiled and converted.
213
203
*/
214
- public generateJson ( src :string [ ] , out :string ) :boolean ;
204
+ public generateJson ( src : string [ ] , out : string ) : boolean ;
215
205
216
206
/**
217
207
* @param project The project that should be converted.
218
208
*/
219
- public generateJson ( project :ProjectReflection , out :string ) :boolean ;
209
+ public generateJson ( project : ProjectReflection , out : string ) : boolean ;
220
210
221
211
/**
222
212
* Run the converter for the given set of files and write the reflections to a json file.
223
213
*
224
214
* @param out The path and file name of the target file.
225
215
* @returns TRUE if the json file could be written successfully, otherwise FALSE.
226
216
*/
227
- public generateJson ( input :any , out :string ) :boolean {
217
+ public generateJson ( input : any , out : string ) : boolean {
228
218
const project = input instanceof ProjectReflection ? input : this . convert ( input ) ;
229
- if ( ! project ) return false ;
219
+ if ( ! project ) {
220
+ return false ;
221
+ }
230
222
231
223
out = Path . resolve ( out ) ;
232
224
writeFile ( out , JSON . stringify ( project . toObject ( ) , null , '\t' ) , false ) ;
@@ -235,7 +227,6 @@ export class Application extends ChildableComponent<Application, AbstractCompone
235
227
return true ;
236
228
}
237
229
238
-
239
230
/**
240
231
* Expand a list of input files.
241
232
*
@@ -246,13 +237,13 @@ export class Application extends ChildableComponent<Application, AbstractCompone
246
237
* @param inputFiles The list of files that should be expanded.
247
238
* @returns The list of input files with expanded directories.
248
239
*/
249
- public expandInputFiles ( inputFiles ?:string [ ] ) :string [ ] {
250
- let exclude :IMinimatch , files :string [ ] = [ ] ;
240
+ public expandInputFiles ( inputFiles ?: string [ ] ) : string [ ] {
241
+ let exclude : IMinimatch , files : string [ ] = [ ] ;
251
242
if ( this . exclude ) {
252
243
exclude = new Minimatch ( this . exclude ) ;
253
244
}
254
245
255
- function add ( dirname :string ) {
246
+ function add ( dirname : string ) {
256
247
FS . readdirSync ( dirname ) . forEach ( ( file ) => {
257
248
const realpath = Path . join ( dirname , file ) ;
258
249
if ( FS . statSync ( realpath ) . isDirectory ( ) ) {
@@ -279,7 +270,6 @@ export class Application extends ChildableComponent<Application, AbstractCompone
279
270
return files ;
280
271
}
281
272
282
-
283
273
/**
284
274
* Print the version number.
285
275
*/
0 commit comments