From 8c12374c4c48bc4d20a223c1c23fce61084abb89 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Sun, 19 Mar 2017 08:35:08 +0000 Subject: [PATCH] build(aio): do not render private classes and members --- aio/transforms/angular.io-package/index.js | 1 + .../processors/filterPrivateDocs.js | 9 +++++ .../processors/filterPrivateDocs.spec.js | 40 +++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 aio/transforms/angular.io-package/processors/filterPrivateDocs.js create mode 100644 aio/transforms/angular.io-package/processors/filterPrivateDocs.spec.js diff --git a/aio/transforms/angular.io-package/index.js b/aio/transforms/angular.io-package/index.js index 5c1546cfd4..3322e17390 100644 --- a/aio/transforms/angular.io-package/index.js +++ b/aio/transforms/angular.io-package/index.js @@ -47,6 +47,7 @@ module.exports = .processor(require('./processors/filterMemberDocs')) .processor(require('./processors/convertToJson')) .processor(require('./processors/markBarredODocsAsPrivate')) + .processor(require('./processors/filterPrivateDocs')) // overrides base packageInfo and returns the one for the 'angular/angular' repo. .factory('packageInfo', function() { return require(path.resolve(PROJECT_ROOT, 'package.json')); }) diff --git a/aio/transforms/angular.io-package/processors/filterPrivateDocs.js b/aio/transforms/angular.io-package/processors/filterPrivateDocs.js new file mode 100644 index 0000000000..08289a3a8e --- /dev/null +++ b/aio/transforms/angular.io-package/processors/filterPrivateDocs.js @@ -0,0 +1,9 @@ +module.exports = function filterPrivateDocs() { + return { + $runAfter: ['extra-docs-added'], + $runBefore: ['computing-paths'], + $process: function(docs) { + return docs.filter(function(doc) { return doc.privateExport !== true }); + } + } +}; \ No newline at end of file diff --git a/aio/transforms/angular.io-package/processors/filterPrivateDocs.spec.js b/aio/transforms/angular.io-package/processors/filterPrivateDocs.spec.js new file mode 100644 index 0000000000..283fcd49bc --- /dev/null +++ b/aio/transforms/angular.io-package/processors/filterPrivateDocs.spec.js @@ -0,0 +1,40 @@ +const testPackage = require('../../helpers/test-package'); +const processorFactory = require('./filterPrivateDocs'); +const Dgeni = require('dgeni'); + +describe('filterPrivateDocs processor', () => { + + it('should be available on the injector', () => { + const dgeni = new Dgeni([testPackage('angular.io-package')]); + const injector = dgeni.configureInjector(); + const processor = injector.get('filterPrivateDocs'); + expect(processor.$process).toBeDefined(); + }); + + it('should run before computing-paths', () => { + const processor = processorFactory(); + expect(processor.$runBefore).toEqual(['computing-paths']) + }); + + it('should run before computing-paths', () => { + const processor = processorFactory(); + expect(processor.$runAfter).toEqual(['extra-docs-added']); + }); + + it('should remove docs that are marked as private exports', () => { + const processor = processorFactory(); + const docs = [ + { name: 'public1'}, + { name: 'ɵPrivate1', privateExport: true }, + { name: 'public2'}, + { name: 'ɵPrivate2', privateExport: true }, + { id: 'other'} + ]; + const filteredDocs = processor.$process(docs); + expect(filteredDocs).toEqual([ + { name: 'public1'}, + { name: 'public2'}, + { id: 'other'} + ]); + }) +}); \ No newline at end of file