@@ -14,10 +14,11 @@ var swaggerHelpers = require('./swagger-helpers');
1414 * Parses the provided API file for JSDoc comments.
1515 * @function
1616 * @param {string } file - File to be parsed
17+ * @param {object } jsDocFilter - Function returning boolean to filter docs
1718 * @returns {{jsdoc: array, yaml: array} } JSDoc comments and Yaml files
1819 * @requires doctrine
1920 */
20- function parseApiFile ( file ) {
21+ function parseApiFile ( file , jsDocFilter ) {
2122 var jsDocRegex = / \/ \* \* ( [ \s \S ] * ?) \* \/ / gm;
2223 var fileContent = fs . readFileSync ( file , { encoding : 'utf8' } ) ;
2324 var ext = path . extname ( file ) ;
@@ -31,7 +32,10 @@ function parseApiFile(file) {
3132 if ( regexResults ) {
3233 for ( var i = 0 ; i < regexResults . length ; i = i + 1 ) {
3334 var jsDocComment = doctrine . parse ( regexResults [ i ] , { unwrap : true } ) ;
34- jsDocComments . push ( jsDocComment ) ;
35+
36+ if ( typeof jsDocFilter !== 'function' || ! ! jsDocFilter ( jsDocComment ) ) {
37+ jsDocComments . push ( jsDocComment ) ;
38+ }
3539 }
3640 }
3741 }
@@ -102,7 +106,7 @@ module.exports = function(options) {
102106
103107 // Parse the documentation in the APIs array.
104108 for ( var i = 0 ; i < apiPaths . length ; i = i + 1 ) {
105- var files = parseApiFile ( apiPaths [ i ] ) ;
109+ var files = parseApiFile ( apiPaths [ i ] , options . jsDocFilter ) ;
106110 var swaggerJsDocComments = filterJsDocComments ( files . jsdoc ) ;
107111
108112 var problems = swaggerHelpers . findDeprecated ( [ files , swaggerJsDocComments ] ) ;
0 commit comments