@@ -10,6 +10,7 @@ var ParameterError = require('./errors/parameter_error');
1010var ParserError = require ( './errors/parser_error' ) ;
1111
1212var app = { } ;
13+ var filterTag = null ;
1314
1415function Parser ( _app ) {
1516 var self = this ;
@@ -49,6 +50,11 @@ function Parser(_app) {
4950 self . addParser ( parser , require ( filename ) ) ;
5051 }
5152 } ) ;
53+
54+ if ( app . options . filterBy ) {
55+ var tag = app . options . filterBy . split ( '=' ) [ 0 ] ;
56+ filterTag = ( tag . indexOf ( 'api' ) != - 1 ) ? tag : null ;
57+ }
5258}
5359
5460/**
@@ -410,8 +416,11 @@ Parser.prototype._findBlocks = function() {
410416 */
411417Parser . prototype . _findBlockWithApiGetIndex = function ( blocks ) {
412418 var foundIndexes = [ ] ;
419+ const valueTofilter = ( filterTag ) ? app . options . filterBy . split ( '=' ) [ 1 ] : null ;
413420 for ( var i = 0 ; i < blocks . length ; i += 1 ) {
414421 var found = false ;
422+ let isToFilterBy = false ;
423+ let isDefine = false ;
415424 for ( var j = 0 ; j < blocks [ i ] . length ; j += 1 ) {
416425 // check apiIgnore
417426 if ( blocks [ i ] [ j ] . name . substr ( 0 , 9 ) === 'apiignore' ) {
@@ -426,10 +435,24 @@ Parser.prototype._findBlockWithApiGetIndex = function(blocks) {
426435 found = false ;
427436 break ;
428437 }
438+ // if (filterTag && blocks[i][j].name.substr(0, 10) === filterTag && blocks[i][j].content !== valueTofilter) {
439+ if ( filterTag ) {
440+ if ( blocks [ i ] [ j ] . name . substr ( 0 , 9 ) === 'apidefine' ) {
441+ isDefine = true ;
442+ }
443+ if ( blocks [ i ] [ j ] . name . substr ( 0 , filterTag . length ) === filterTag && blocks [ i ] [ j ] . content === valueTofilter ) {
444+ isToFilterBy = true ;
445+ }
446+ }
429447
430448 if ( blocks [ i ] [ j ] . name . substr ( 0 , 3 ) === 'api' )
431449 found = true ;
432450 }
451+
452+ if ( filterTag ) {
453+ found = found && ( isToFilterBy || isDefine ) ;
454+ }
455+
433456 if ( found ) {
434457 foundIndexes . push ( i ) ;
435458 app . log . debug ( 'api found in block: ' + i ) ;
0 commit comments