@@ -15,8 +15,12 @@ const enginesDirectories = [{
15
15
path : path . join ( process . cwd ( ) , 'node_modules' )
16
16
} ] ;
17
17
18
- // given a path: return the engine name if the path points to a valid engine
19
- // module directory, or false if it doesn't
18
+ /**
19
+ * Given a path: return the engine name if the path points to a valid engine
20
+ * module directory, or false if it doesn't.
21
+ * @param filePath
22
+ * @returns Engine name if exists or FALSE
23
+ */
20
24
function isEngineModule ( filePath ) {
21
25
const baseName = path . basename ( filePath ) ;
22
26
const engineMatch = baseName . match ( engineMatcher ) ;
@@ -118,6 +122,11 @@ function findEngineModulesInDirectory(dir) {
118
122
119
123
const PatternEngines = Object . create ( {
120
124
125
+ /**
126
+ * Load all pattern engines.
127
+ * @param patternLabConfig
128
+ * @memberof PatternEngines
129
+ */
121
130
loadAllEngines : function ( patternLabConfig ) {
122
131
var self = this ;
123
132
@@ -165,6 +174,12 @@ const PatternEngines = Object.create({
165
174
logger . debug ( `Done loading engines` ) ;
166
175
} ,
167
176
177
+ /**
178
+ * Get engine name for pattern.
179
+ * @memberof PatternEngines
180
+ * @param pattern
181
+ * @returns engine name matching pattern
182
+ */
168
183
getEngineNameForPattern : function ( pattern ) {
169
184
// avoid circular dependency by putting this in here. TODO: is this slow?
170
185
const of = require ( './object_factory' ) ;
@@ -192,6 +207,12 @@ const PatternEngines = Object.create({
192
207
return 'mustache' ;
193
208
} ,
194
209
210
+ /**
211
+ * Get engine for pattern.
212
+ * @memberof PatternEngines
213
+ * @param pattern
214
+ * @returns name of engine for pattern
215
+ */
195
216
getEngineForPattern : function ( pattern ) {
196
217
if ( pattern . isPseudoPattern ) {
197
218
return this . getEngineForPattern ( pattern . basePattern ) ;
@@ -201,7 +222,11 @@ const PatternEngines = Object.create({
201
222
}
202
223
} ,
203
224
204
- // combine all found engines into a single array of supported extensions
225
+ /**
226
+ * Combine all found engines into a single array of supported extensions.
227
+ * @memberof PatternEngines
228
+ * @returns Array all supported file extensions
229
+ */
205
230
getSupportedFileExtensions : function ( ) {
206
231
const engineNames = Object . keys ( PatternEngines ) ;
207
232
const allEnginesExtensions = engineNames . map ( ( engineName ) => {
@@ -210,22 +235,38 @@ const PatternEngines = Object.create({
210
235
return [ ] . concat . apply ( [ ] , allEnginesExtensions ) ;
211
236
} ,
212
237
238
+ /**
239
+ * Check if fileExtension is supported.
240
+ * @memberof PatternEngines
241
+ * @param fileExtension
242
+ * @returns Boolean
243
+ */
213
244
isFileExtensionSupported : function ( fileExtension ) {
214
245
const supportedExtensions = PatternEngines . getSupportedFileExtensions ( ) ;
215
246
return ( supportedExtensions . lastIndexOf ( fileExtension ) !== - 1 ) ;
216
247
} ,
217
248
218
- // given a filename, return a boolean: whether or not the filename indicates
219
- // that the file is pseudopattern JSON
249
+ /**
250
+ * Given a filename, return a boolean: whether or not the filename indicates
251
+ * that the file is pseudopattern JSON
252
+ * @param filename
253
+ * @return boolean
254
+ */
220
255
isPseudoPatternJSON : function ( filename ) {
221
256
const extension = path . extname ( filename ) ;
222
257
return ( extension === '.json' && filename . indexOf ( '~' ) > - 1 ) ;
223
258
} ,
224
259
225
- // takes a filename string, not a full path; a basename (plus extension)
226
- // ignore _underscored patterns, dotfiles, and anything not recognized by a
227
- // loaded pattern engine. Pseudo-pattern .json files ARE considered to be
228
- // pattern files!
260
+ /**
261
+ * Takes a filename string, not a full path; a basename (plus extension)
262
+ * ignore _underscored patterns, dotfiles, and anything not recognized by a
263
+ * loaded pattern engine. Pseudo-pattern .json files ARE considered to be
264
+ * pattern files!
265
+ *
266
+ * @memberof PatternEngines
267
+ * @param filename
268
+ * @returns boolean
269
+ */
229
270
isPatternFile : function ( filename ) {
230
271
// skip hidden patterns/files without a second thought
231
272
const extension = path . extname ( filename ) ;
0 commit comments