diff --git a/public/api-builder/angular.io-package/index.js b/public/api-builder/angular.io-package/index.js index 7d2b21dd27..9e1bc97c10 100644 --- a/public/api-builder/angular.io-package/index.js +++ b/public/api-builder/angular.io-package/index.js @@ -6,6 +6,7 @@ module.exports = new Package('angular.io', [basePackage]) .factory(require('./services/renderMarkdown')) .processor(require('./processors/addJadeDataDocsProcessor')) +.processor(require('./processors/filterUnwantedDecorators')) // overrides base packageInfo and returns the one for the 'angular/angular' repo. .factory(require('./services/packageInfo')) @@ -88,4 +89,12 @@ module.exports = new Package('angular.io', [basePackage]) ])); }) +.config(function(filterUnwantedDecorators, log) { + log.level = 'info'; + filterUnwantedDecorators.decoratorsToIgnore = [ + 'CONST', + 'IMPLEMENTS', + 'ABSTRACT' + ]; +}) diff --git a/public/api-builder/angular.io-package/processors/filterUnwantedDecorators.js b/public/api-builder/angular.io-package/processors/filterUnwantedDecorators.js new file mode 100644 index 0000000000..1f321bd42b --- /dev/null +++ b/public/api-builder/angular.io-package/processors/filterUnwantedDecorators.js @@ -0,0 +1,20 @@ +var _ = require('lodash'); + +module.exports = function filterUnwantedDecorators() { + return { + decoratorsToIgnore: [], + $runAfter: ['processing-docs'], + $runBefore: ['docs-processed'], + $process: function(docs) { + var decoratorsToIgnore = this.decoratorsToIgnore || []; + _.forEach(docs, function(doc) { + if (doc.decorators) { + doc.decorators = _.filter(doc.decorators, function(decorator) { + return decoratorsToIgnore.indexOf(decorator.name) === -1; + }); + } + }); + return docs; + } + }; +} \ No newline at end of file diff --git a/public/api-builder/angular.io-package/processors/filterUnwantedDecorators.spec.js b/public/api-builder/angular.io-package/processors/filterUnwantedDecorators.spec.js new file mode 100644 index 0000000000..47a88f8408 --- /dev/null +++ b/public/api-builder/angular.io-package/processors/filterUnwantedDecorators.spec.js @@ -0,0 +1,46 @@ +var mockPackage = require('../mocks/mockPackage'); +var Dgeni = require('dgeni'); + +describe('filterUnwantedDecorators', function() { + var dgeni, injector, processor; + + beforeEach(function() { + dgeni = new Dgeni([mockPackage()]); + injector = dgeni.configureInjector(); + processor = injector.get('filterUnwantedDecorators'); + }); + + + it('should remove decorators specified by name', function() { + var docs = [ + { id: 'doc1', decorators: [ { name: 'A' }, { name: 'B' } ] }, + { id: 'doc2', decorators: [ { name: 'B' }, { name: 'C' } ] }, + { id: 'doc3', decorators: [ { name: 'A' }, { name: 'C' } ] } + ]; + processor.decoratorsToIgnore = ['D', 'B']; + docs = processor.$process(docs); + + expect(docs).toEqual([ + { id: 'doc1', decorators: [ { name: 'A' } ] }, + { id: 'doc2', decorators: [ { name: 'C' } ] }, + { id: 'doc3', decorators: [ { name: 'A' }, { name: 'C' } ] } + ]); + }); + + + it('should ignore docs that have no decorators', function() { + var docs = [ + { id: 'doc1', decorators: [ { name: 'A' }, { name: 'B' } ] }, + { id: 'doc2' }, + { id: 'doc3', decorators: [ { name: 'A' }, { name: 'C' } ] } + ]; + processor.decoratorsToIgnore = ['D', 'B']; + docs = processor.$process(docs); + + expect(docs).toEqual([ + { id: 'doc1', decorators: [ { name: 'A' } ] }, + { id: 'doc2' }, + { id: 'doc3', decorators: [ { name: 'A' }, { name: 'C' } ] } + ]); + }); +}); \ No newline at end of file