diff --git a/docs/angular.io-package/index.js b/docs/angular.io-package/index.js index 240900e3f6..9d419278b6 100644 --- a/docs/angular.io-package/index.js +++ b/docs/angular.io-package/index.js @@ -9,6 +9,7 @@ module.exports = new Package('angular.io', [basePackage]) .factory(require('./services/renderMarkdown')) .processor(require('./processors/addJadeDataDocsProcessor')) +.processor(require('./processors/filterUnwantedDecorators')) // Configure rendering .config(function(templateFinder, templateEngine) { @@ -29,6 +30,14 @@ module.exports = new Package('angular.io', [basePackage]) }) +.config(function(filterUnwantedDecorators, log) { + log.level = 'info'; + filterUnwantedDecorators.decoratorsToIgnore = [ + 'CONST', + 'IMPLEMENTS', + 'ABSTRACT' + ]; +}) .config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) { diff --git a/docs/angular.io-package/processors/filterUnwantedDecorators.js b/docs/angular.io-package/processors/filterUnwantedDecorators.js new file mode 100644 index 0000000000..f790cb6d91 --- /dev/null +++ b/docs/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; + } + }; +} diff --git a/docs/angular.io-package/processors/filterUnwantedDecorators.spec.js b/docs/angular.io-package/processors/filterUnwantedDecorators.spec.js new file mode 100644 index 0000000000..c240e6f02a --- /dev/null +++ b/docs/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' } ] } + ]); + }); +});