diff --git a/aio/transforms/angular.io-package/index.js b/aio/transforms/angular.io-package/index.js index d696d9d9bf..5c1546cfd4 100644 --- a/aio/transforms/angular.io-package/index.js +++ b/aio/transforms/angular.io-package/index.js @@ -46,6 +46,7 @@ module.exports = .processor(require('./processors/matchUpDirectiveDecorators')) .processor(require('./processors/filterMemberDocs')) .processor(require('./processors/convertToJson')) + .processor(require('./processors/markBarredODocsAsPrivate')) // 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/generateApiListDoc.js b/aio/transforms/angular.io-package/processors/generateApiListDoc.js index fbc42a449b..f2311adcc1 100644 --- a/aio/transforms/angular.io-package/processors/generateApiListDoc.js +++ b/aio/transforms/angular.io-package/processors/generateApiListDoc.js @@ -24,7 +24,9 @@ function getModuleInfo(moduleDoc) { return { name: moduleName.toLowerCase(), title: moduleName, - items: moduleDoc.exports.filter(doc => !doc.internal).map(getExportInfo) + items: moduleDoc.exports + // Ignore internals and private exports (indicated by the ɵ prefix) + .filter(doc => !doc.internal && !doc.privateExport).map(getExportInfo) }; } diff --git a/aio/transforms/angular.io-package/processors/generateApiListDoc.spec.js b/aio/transforms/angular.io-package/processors/generateApiListDoc.spec.js index a8e2fa32c1..515dccce8c 100644 --- a/aio/transforms/angular.io-package/processors/generateApiListDoc.spec.js +++ b/aio/transforms/angular.io-package/processors/generateApiListDoc.spec.js @@ -83,11 +83,12 @@ describe('generateApiListDoc processor', () => { ]); }); - it('should ignore internal exports', () => { + it('should ignore internal and private exports', () => { const processor = processorFactory(); const docs = [ { docType: 'module', id: '@angular/common/index', exports: [ { docType: 'directive', name: 'AaaAaa', path: 'aaa', internal: true }, + { docType: 'class', name: 'XxxXxx', path: 'xxx', privateExport: true }, { docType: 'pipe', name: 'BbbBbb', path: 'bbb' } ]} ]; diff --git a/aio/transforms/angular.io-package/processors/generateKeywords.js b/aio/transforms/angular.io-package/processors/generateKeywords.js index 4af71f681a..9e16cefa04 100644 --- a/aio/transforms/angular.io-package/processors/generateKeywords.js +++ b/aio/transforms/angular.io-package/processors/generateKeywords.js @@ -76,8 +76,11 @@ module.exports = function generateKeywordsProcessor(log, readFilesProcessor) { } - // We are only interested in docs that live in the right area - const filteredDocs = docs.filter(function(doc) { return !docTypesToIgnore[doc.docType]; }); + const filteredDocs = docs + // We are not interested in some docTypes + .filter(function(doc) { return !docTypesToIgnore[doc.docType]; }) + // Ignore internals and private exports (indicated by the ɵ prefix) + .filter(function(doc) { return !doc.internal && !doc.privateExport; }); filteredDocs.forEach(function(doc) { diff --git a/aio/transforms/angular.io-package/processors/generateKeywords.spec.js b/aio/transforms/angular.io-package/processors/generateKeywords.spec.js new file mode 100644 index 0000000000..fbd33bda2d --- /dev/null +++ b/aio/transforms/angular.io-package/processors/generateKeywords.spec.js @@ -0,0 +1,41 @@ +const testPackage = require('../../helpers/test-package'); +const mockLogger = require('dgeni/lib/mocks/log')(false); +const processorFactory = require('./generateKeywords'); +const Dgeni = require('dgeni'); + +const mockReadFilesProcessor = { + basePath: 'base/path' +}; + +describe('generateKeywords processor', () => { + + it('should be available on the injector', () => { + const dgeni = new Dgeni([testPackage('angular.io-package')]); + const injector = dgeni.configureInjector(); + const processor = injector.get('generateKeywordsProcessor'); + expect(processor.$process).toBeDefined(); + }); + + it('should run after "paths-computed"', () => { + const processor = processorFactory(mockLogger, mockReadFilesProcessor); + expect(processor.$runAfter).toEqual(['paths-computed']); + }); + + it('should run before "rendering-docs"', () => { + const processor = processorFactory(mockLogger, mockReadFilesProcessor); + expect(processor.$runBefore).toEqual(['rendering-docs']); + }); + + it('should ignore internal and private exports', () => { + const processor = processorFactory(mockLogger, mockReadFilesProcessor); + const docs = [ + { docType: 'class', name: 'PublicExport' }, + { docType: 'class', name: 'PrivateExport', privateExport: true }, + { docType: 'class', name: 'InternalExport', internal: true } + ]; + processor.$process(docs); + expect(docs[docs.length - 1].data).toEqual([ + jasmine.objectContaining({ title: 'PublicExport', type: 'class'}) + ]); + }); +}); diff --git a/aio/transforms/angular.io-package/processors/markBarredODocsAsPrivate.js b/aio/transforms/angular.io-package/processors/markBarredODocsAsPrivate.js new file mode 100644 index 0000000000..702811b562 --- /dev/null +++ b/aio/transforms/angular.io-package/processors/markBarredODocsAsPrivate.js @@ -0,0 +1,13 @@ +module.exports = function markBarredODocsAsPrivate() { + return { + $runAfter: ['readTypeScriptModules'], + $runBefore: ['adding-extra-docs'], + $process: function(docs) { + docs.forEach(doc => { + if (doc.name && doc.name.indexOf('ɵ') === 0) { + doc.privateExport = true; + } + }); + } + }; +}; diff --git a/aio/transforms/angular.io-package/processors/markBarredODocsAsPrivate.spec.js b/aio/transforms/angular.io-package/processors/markBarredODocsAsPrivate.spec.js new file mode 100644 index 0000000000..c2a403d1a9 --- /dev/null +++ b/aio/transforms/angular.io-package/processors/markBarredODocsAsPrivate.spec.js @@ -0,0 +1,28 @@ +const testPackage = require('../../helpers/test-package'); +const processorFactory = require('./markBarredODocsAsPrivate'); +const Dgeni = require('dgeni'); + +describe('generateApiListDoc processor', () => { + + it('should be available on the injector', () => { + const dgeni = new Dgeni([testPackage('angular.io-package')]); + const injector = dgeni.configureInjector(); + const processor = injector.get('markBarredODocsAsPrivate'); + expect(processor.$process).toBeDefined(); + expect(processor.$runAfter).toContain('readTypeScriptModules'); + expect(processor.$runBefore).toContain('adding-extra-docs'); + }); + + it('should mark docs starting with barred-o ɵ as private', () => { + const processor = processorFactory(); + const docs = [ + { name: 'ɵPrivate' }, + { name: 'public' } + ] + processor.$process(docs); + + expect(docs[0].privateExport).toBeTruthy(); + expect(docs[1].privateExport).toBeFalsy(); + }); +}); +