@@ -15,8 +15,12 @@ const enginesDirectories = [
15
15
}
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 ) ;
@@ -25,6 +29,11 @@ function isEngineModule(filePath) {
25
29
return false ;
26
30
}
27
31
32
+ /**
33
+ * Find engine modules in a given directory.
34
+ * @param dir Directory containing engine modules
35
+ * @returns Array of engine modules keyed by engine name
36
+ */
28
37
function findEngineModulesInDirectory ( dir ) {
29
38
const foundEngines = [ ] ;
30
39
@@ -62,6 +71,11 @@ function findEngineModulesInDirectory(dir) {
62
71
63
72
const PatternEngines = Object . create ( {
64
73
74
+ /**
75
+ * Load all pattern engines.
76
+ * @param patternLabConfig
77
+ * @memberof PatternEngines
78
+ */
65
79
loadAllEngines : function ( patternLabConfig ) {
66
80
var self = this ;
67
81
@@ -118,6 +132,12 @@ const PatternEngines = Object.create({
118
132
}
119
133
} ,
120
134
135
+ /**
136
+ * Get engine name for pattern.
137
+ * @memberof PatternEngines
138
+ * @param pattern
139
+ * @returns engine name matching pattern
140
+ */
121
141
getEngineNameForPattern : function ( pattern ) {
122
142
// avoid circular dependency by putting this in here. TODO: is this slow?
123
143
const of = require ( './object_factory' ) ;
@@ -145,6 +165,12 @@ const PatternEngines = Object.create({
145
165
return 'mustache' ;
146
166
} ,
147
167
168
+ /**
169
+ * Get engine for pattern.
170
+ * @memberof PatternEngines
171
+ * @param pattern
172
+ * @returns name of engine for pattern
173
+ */
148
174
getEngineForPattern : function ( pattern ) {
149
175
if ( pattern . isPseudoPattern ) {
150
176
return this . getEngineForPattern ( pattern . basePattern ) ;
@@ -154,7 +180,11 @@ const PatternEngines = Object.create({
154
180
}
155
181
} ,
156
182
157
- // combine all found engines into a single array of supported extensions
183
+ /**
184
+ * Combine all found engines into a single array of supported extensions.
185
+ * @memberof PatternEngines
186
+ * @returns Array all supported file extensions
187
+ */
158
188
getSupportedFileExtensions : function ( ) {
159
189
const engineNames = Object . keys ( PatternEngines ) ;
160
190
const allEnginesExtensions = engineNames . map ( ( engineName ) => {
@@ -163,22 +193,38 @@ const PatternEngines = Object.create({
163
193
return [ ] . concat . apply ( [ ] , allEnginesExtensions ) ;
164
194
} ,
165
195
196
+ /**
197
+ * Check if fileExtension is supported.
198
+ * @memberof PatternEngines
199
+ * @param fileExtension
200
+ * @returns Boolean
201
+ */
166
202
isFileExtensionSupported : function ( fileExtension ) {
167
203
const supportedExtensions = PatternEngines . getSupportedFileExtensions ( ) ;
168
204
return ( supportedExtensions . lastIndexOf ( fileExtension ) !== - 1 ) ;
169
205
} ,
170
206
171
- // given a filename, return a boolean: whether or not the filename indicates
172
- // that the file is pseudopattern JSON
207
+ /**
208
+ * Given a filename, return a boolean: whether or not the filename indicates
209
+ * that the file is pseudopattern JSON
210
+ * @param filename
211
+ * @return boolean
212
+ */
173
213
isPseudoPatternJSON : function ( filename ) {
174
214
const extension = path . extname ( filename ) ;
175
215
return ( extension === '.json' && filename . indexOf ( '~' ) > - 1 ) ;
176
216
} ,
177
217
178
- // takes a filename string, not a full path; a basename (plus extension)
179
- // ignore _underscored patterns, dotfiles, and anything not recognized by a
180
- // loaded pattern engine. Pseudo-pattern .json files ARE considered to be
181
- // pattern files!
218
+ /**
219
+ * Takes a filename string, not a full path; a basename (plus extension)
220
+ * ignore _underscored patterns, dotfiles, and anything not recognized by a
221
+ * loaded pattern engine. Pseudo-pattern .json files ARE considered to be
222
+ * pattern files!
223
+ *
224
+ * @memberof PatternEngines
225
+ * @param filename
226
+ * @returns boolean
227
+ */
182
228
isPatternFile : function ( filename ) {
183
229
// skip hidden patterns/files without a second thought
184
230
const extension = path . extname ( filename ) ;
0 commit comments