Skip to content

Commit 7a5e13d

Browse files
committed
First pass at creating jsDoc for pattern_engine.js
1 parent 4bb20ee commit 7a5e13d

File tree

1 file changed

+55
-9
lines changed

1 file changed

+55
-9
lines changed

core/lib/pattern_engines.js

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ const enginesDirectories = [
1515
}
1616
];
1717

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+
*/
2024
function isEngineModule(filePath) {
2125
const baseName = path.basename(filePath);
2226
const engineMatch = baseName.match(engineMatcher);
@@ -25,6 +29,11 @@ function isEngineModule(filePath) {
2529
return false;
2630
}
2731

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+
*/
2837
function findEngineModulesInDirectory(dir) {
2938
const foundEngines = [];
3039

@@ -62,6 +71,11 @@ function findEngineModulesInDirectory(dir) {
6271

6372
const PatternEngines = Object.create({
6473

74+
/**
75+
* Load all pattern engines.
76+
* @param patternLabConfig
77+
* @memberof PatternEngines
78+
*/
6579
loadAllEngines: function (patternLabConfig) {
6680
var self = this;
6781

@@ -118,6 +132,12 @@ const PatternEngines = Object.create({
118132
}
119133
},
120134

135+
/**
136+
* Get engine name for pattern.
137+
* @memberof PatternEngines
138+
* @param pattern
139+
* @returns engine name matching pattern
140+
*/
121141
getEngineNameForPattern: function (pattern) {
122142
// avoid circular dependency by putting this in here. TODO: is this slow?
123143
const of = require('./object_factory');
@@ -145,6 +165,12 @@ const PatternEngines = Object.create({
145165
return 'mustache';
146166
},
147167

168+
/**
169+
* Get engine for pattern.
170+
* @memberof PatternEngines
171+
* @param pattern
172+
* @returns name of engine for pattern
173+
*/
148174
getEngineForPattern: function (pattern) {
149175
if (pattern.isPseudoPattern) {
150176
return this.getEngineForPattern(pattern.basePattern);
@@ -154,7 +180,11 @@ const PatternEngines = Object.create({
154180
}
155181
},
156182

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+
*/
158188
getSupportedFileExtensions: function () {
159189
const engineNames = Object.keys(PatternEngines);
160190
const allEnginesExtensions = engineNames.map((engineName) => {
@@ -163,22 +193,38 @@ const PatternEngines = Object.create({
163193
return [].concat.apply([], allEnginesExtensions);
164194
},
165195

196+
/**
197+
* Check if fileExtension is supported.
198+
* @memberof PatternEngines
199+
* @param fileExtension
200+
* @returns Boolean
201+
*/
166202
isFileExtensionSupported: function (fileExtension) {
167203
const supportedExtensions = PatternEngines.getSupportedFileExtensions();
168204
return (supportedExtensions.lastIndexOf(fileExtension) !== -1);
169205
},
170206

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+
*/
173213
isPseudoPatternJSON: function (filename) {
174214
const extension = path.extname(filename);
175215
return (extension === '.json' && filename.indexOf('~') > -1);
176216
},
177217

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+
*/
182228
isPatternFile: function (filename) {
183229
// skip hidden patterns/files without a second thought
184230
const extension = path.extname(filename);

0 commit comments

Comments
 (0)