refactor(ivy): Move instructions back to ɵɵ (#30546)
There is an encoding issue with using delta `Δ`, where the browser will attempt to detect the file encoding if the character set is not explicitly declared on a `<script/>` tag, and Chrome will find the `Δ` character and decide it is window-1252 encoding, which misinterprets the `Δ` character to be some other character that is not a valid JS identifier character So back to the frog eyes we go. ``` __ /ɵɵ\ ( -- ) - I am ineffable. I am forever. _/ \_ / \ / \ == == == ``` PR Close #30546
This commit is contained in:
344
aio/tools/transforms/angular-api-package/index.js
vendored
344
aio/tools/transforms/angular-api-package/index.js
vendored
@ -9,198 +9,210 @@ const Package = require('dgeni').Package;
|
||||
|
||||
const basePackage = require('../angular-base-package');
|
||||
const typeScriptPackage = require('dgeni-packages/typescript');
|
||||
const { API_SOURCE_PATH, API_TEMPLATES_PATH, requireFolder } = require('../config');
|
||||
const {API_SOURCE_PATH, API_TEMPLATES_PATH, requireFolder} = require('../config');
|
||||
|
||||
module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
||||
module.exports =
|
||||
new Package('angular-api', [basePackage, typeScriptPackage])
|
||||
|
||||
// Register the processors
|
||||
.processor(require('./processors/splitDescription'))
|
||||
.processor(require('./processors/convertPrivateClassesToInterfaces'))
|
||||
.processor(require('./processors/generateApiListDoc'))
|
||||
.processor(require('./processors/addNotYetDocumentedProperty'))
|
||||
.processor(require('./processors/mergeDecoratorDocs'))
|
||||
.processor(require('./processors/extractDecoratedClasses'))
|
||||
.processor(require('./processors/extractPipeParams'))
|
||||
.processor(require('./processors/matchUpDirectiveDecorators'))
|
||||
.processor(require('./processors/addMetadataAliases'))
|
||||
.processor(require('./processors/computeApiBreadCrumbs'))
|
||||
.processor(require('./processors/filterContainedDocs'))
|
||||
.processor(require('./processors/processClassLikeMembers'))
|
||||
.processor(require('./processors/markBarredODocsAsPrivate'))
|
||||
.processor(require('./processors/filterPrivateDocs'))
|
||||
.processor(require('./processors/computeSearchTitle'))
|
||||
.processor(require('./processors/simplifyMemberAnchors'))
|
||||
.processor(require('./processors/computeStability'))
|
||||
.processor(require('./processors/removeInjectableConstructors'))
|
||||
.processor(require('./processors/collectPackageContentDocs'))
|
||||
.processor(require('./processors/processPackages'))
|
||||
.processor(require('./processors/processNgModuleDocs'))
|
||||
.processor(require('./processors/fixupRealProjectRelativePath'))
|
||||
.processor(require('./processors/processAliasDocs'))
|
||||
// Register the processors
|
||||
.processor(require('./processors/splitDescription'))
|
||||
.processor(require('./processors/convertPrivateClassesToInterfaces'))
|
||||
.processor(require('./processors/generateApiListDoc'))
|
||||
.processor(require('./processors/addNotYetDocumentedProperty'))
|
||||
.processor(require('./processors/mergeDecoratorDocs'))
|
||||
.processor(require('./processors/extractDecoratedClasses'))
|
||||
.processor(require('./processors/extractPipeParams'))
|
||||
.processor(require('./processors/matchUpDirectiveDecorators'))
|
||||
.processor(require('./processors/addMetadataAliases'))
|
||||
.processor(require('./processors/computeApiBreadCrumbs'))
|
||||
.processor(require('./processors/filterContainedDocs'))
|
||||
.processor(require('./processors/processClassLikeMembers'))
|
||||
.processor(require('./processors/markBarredODocsAsPrivate'))
|
||||
.processor(require('./processors/filterPrivateDocs'))
|
||||
.processor(require('./processors/computeSearchTitle'))
|
||||
.processor(require('./processors/simplifyMemberAnchors'))
|
||||
.processor(require('./processors/computeStability'))
|
||||
.processor(require('./processors/removeInjectableConstructors'))
|
||||
.processor(require('./processors/collectPackageContentDocs'))
|
||||
.processor(require('./processors/processPackages'))
|
||||
.processor(require('./processors/processNgModuleDocs'))
|
||||
.processor(require('./processors/fixupRealProjectRelativePath'))
|
||||
.processor(require('./processors/processAliasDocs'))
|
||||
|
||||
|
||||
/**
|
||||
* These are the API doc types that will be rendered to actual files.
|
||||
* This is a super set of the exported docs, since we convert some classes to
|
||||
* more Angular specific API types, such as decorators and directives.
|
||||
*/
|
||||
.factory(function API_DOC_TYPES_TO_RENDER(EXPORT_DOC_TYPES) {
|
||||
return EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe', 'package']);
|
||||
})
|
||||
/**
|
||||
* These are the API doc types that will be rendered to actual files.
|
||||
* This is a super set of the exported docs, since we convert some classes to
|
||||
* more Angular specific API types, such as decorators and directives.
|
||||
*/
|
||||
.factory(function API_DOC_TYPES_TO_RENDER(EXPORT_DOC_TYPES) {
|
||||
return EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe', 'package']);
|
||||
})
|
||||
|
||||
/**
|
||||
* These are the doc types that are contained within other docs
|
||||
*/
|
||||
.factory(function API_CONTAINED_DOC_TYPES() {
|
||||
return ['member', 'function-overload', 'get-accessor-info', 'set-accessor-info', 'parameter'];
|
||||
})
|
||||
/**
|
||||
* These are the doc types that are contained within other docs
|
||||
*/
|
||||
.factory(function API_CONTAINED_DOC_TYPES() {
|
||||
return [
|
||||
'member', 'function-overload', 'get-accessor-info', 'set-accessor-info', 'parameter'
|
||||
];
|
||||
})
|
||||
|
||||
/**
|
||||
* These are the doc types that are API docs, including ones that will be merged into container docs,
|
||||
* such as members and overloads.
|
||||
*/
|
||||
.factory(function API_DOC_TYPES(API_DOC_TYPES_TO_RENDER, API_CONTAINED_DOC_TYPES) {
|
||||
return API_DOC_TYPES_TO_RENDER.concat(API_CONTAINED_DOC_TYPES);
|
||||
})
|
||||
/**
|
||||
* These are the doc types that are API docs, including ones that will be merged into
|
||||
* container docs,
|
||||
* such as members and overloads.
|
||||
*/
|
||||
.factory(function API_DOC_TYPES(API_DOC_TYPES_TO_RENDER, API_CONTAINED_DOC_TYPES) {
|
||||
return API_DOC_TYPES_TO_RENDER.concat(API_CONTAINED_DOC_TYPES);
|
||||
})
|
||||
|
||||
.factory(require('./readers/package-content'))
|
||||
.factory(require('./readers/package-content'))
|
||||
|
||||
// Where do we get the source files?
|
||||
.config(function(readTypeScriptModules, readFilesProcessor, collectExamples, tsParser, packageContentFileReader) {
|
||||
// Where do we get the source files?
|
||||
.config(function(
|
||||
readTypeScriptModules, readFilesProcessor, collectExamples, tsParser,
|
||||
packageContentFileReader) {
|
||||
|
||||
// Tell TypeScript how to load modules that start with with `@angular`
|
||||
tsParser.options.paths = { '@angular/*': [API_SOURCE_PATH + '/*'] };
|
||||
tsParser.options.baseUrl = '.';
|
||||
// Tell TypeScript how to load modules that start with with `@angular`
|
||||
tsParser.options.paths = {'@angular/*': [API_SOURCE_PATH + '/*']};
|
||||
tsParser.options.baseUrl = '.';
|
||||
|
||||
// API files are typescript
|
||||
readTypeScriptModules.basePath = API_SOURCE_PATH;
|
||||
readTypeScriptModules.ignoreExportsMatching = [/^_|^Δ|^VERSION$/];
|
||||
readTypeScriptModules.hidePrivateMembers = true;
|
||||
// API files are typescript
|
||||
readTypeScriptModules.basePath = API_SOURCE_PATH;
|
||||
readTypeScriptModules.ignoreExportsMatching = [/^_|^ɵɵ|^VERSION$/];
|
||||
readTypeScriptModules.hidePrivateMembers = true;
|
||||
|
||||
// NOTE: This list should be in sync with tools/public_api_guard/BUILD.bazel
|
||||
readTypeScriptModules.sourceFiles = [
|
||||
'animations/index.ts',
|
||||
'animations/browser/index.ts',
|
||||
'animations/browser/testing/index.ts',
|
||||
'common/http/index.ts',
|
||||
'common/http/testing/index.ts',
|
||||
'common/index.ts',
|
||||
'common/testing/index.ts',
|
||||
'common/upgrade/index.ts',
|
||||
'core/index.ts',
|
||||
'core/testing/index.ts',
|
||||
'elements/index.ts',
|
||||
'forms/index.ts',
|
||||
// Current plan for Angular v8 is to hide documentation for the @angular/http package
|
||||
// 'http/index.ts',
|
||||
// 'http/testing/index.ts',
|
||||
'platform-browser/index.ts',
|
||||
'platform-browser/animations/index.ts',
|
||||
'platform-browser/testing/index.ts',
|
||||
'platform-browser-dynamic/index.ts',
|
||||
'platform-browser-dynamic/testing/index.ts',
|
||||
'platform-server/index.ts',
|
||||
'platform-server/testing/index.ts',
|
||||
'platform-webworker/index.ts',
|
||||
'platform-webworker-dynamic/index.ts',
|
||||
'router/index.ts',
|
||||
'router/testing/index.ts',
|
||||
'router/upgrade/index.ts',
|
||||
'service-worker/index.ts',
|
||||
'upgrade/index.ts',
|
||||
'upgrade/static/index.ts',
|
||||
];
|
||||
// NOTE: This list should be in sync with tools/public_api_guard/BUILD.bazel
|
||||
readTypeScriptModules.sourceFiles = [
|
||||
'animations/index.ts',
|
||||
'animations/browser/index.ts',
|
||||
'animations/browser/testing/index.ts',
|
||||
'common/http/index.ts',
|
||||
'common/http/testing/index.ts',
|
||||
'common/index.ts',
|
||||
'common/testing/index.ts',
|
||||
'common/upgrade/index.ts',
|
||||
'core/index.ts',
|
||||
'core/testing/index.ts',
|
||||
'elements/index.ts',
|
||||
'forms/index.ts',
|
||||
// Current plan for Angular v8 is to hide documentation for the @angular/http package
|
||||
// 'http/index.ts',
|
||||
// 'http/testing/index.ts',
|
||||
'platform-browser/index.ts',
|
||||
'platform-browser/animations/index.ts',
|
||||
'platform-browser/testing/index.ts',
|
||||
'platform-browser-dynamic/index.ts',
|
||||
'platform-browser-dynamic/testing/index.ts',
|
||||
'platform-server/index.ts',
|
||||
'platform-server/testing/index.ts',
|
||||
'platform-webworker/index.ts',
|
||||
'platform-webworker-dynamic/index.ts',
|
||||
'router/index.ts',
|
||||
'router/testing/index.ts',
|
||||
'router/upgrade/index.ts',
|
||||
'service-worker/index.ts',
|
||||
'upgrade/index.ts',
|
||||
'upgrade/static/index.ts',
|
||||
];
|
||||
|
||||
readFilesProcessor.fileReaders.push(packageContentFileReader);
|
||||
readFilesProcessor.fileReaders.push(packageContentFileReader);
|
||||
|
||||
// API Examples
|
||||
readFilesProcessor.sourceFiles = [
|
||||
{
|
||||
basePath: API_SOURCE_PATH,
|
||||
include: API_SOURCE_PATH + '/examples/**/*',
|
||||
fileReader: 'exampleFileReader'
|
||||
},
|
||||
{
|
||||
basePath: API_SOURCE_PATH,
|
||||
include: API_SOURCE_PATH + '/**/PACKAGE.md',
|
||||
fileReader: 'packageContentFileReader'
|
||||
}
|
||||
];
|
||||
collectExamples.exampleFolders.push('examples');
|
||||
})
|
||||
// API Examples
|
||||
readFilesProcessor.sourceFiles = [
|
||||
{
|
||||
basePath: API_SOURCE_PATH,
|
||||
include: API_SOURCE_PATH + '/examples/**/*',
|
||||
fileReader: 'exampleFileReader'
|
||||
},
|
||||
{
|
||||
basePath: API_SOURCE_PATH,
|
||||
include: API_SOURCE_PATH + '/**/PACKAGE.md',
|
||||
fileReader: 'packageContentFileReader'
|
||||
}
|
||||
];
|
||||
collectExamples.exampleFolders.push('examples');
|
||||
})
|
||||
|
||||
// Configure jsdoc-style tag parsing
|
||||
.config(function(parseTagsProcessor, getInjectables, tsHost) {
|
||||
// Load up all the tag definitions in the tag-defs folder
|
||||
parseTagsProcessor.tagDefinitions =
|
||||
parseTagsProcessor.tagDefinitions.concat(getInjectables(requireFolder(__dirname, './tag-defs')));
|
||||
// We don't want license headers to be joined to the first API item's comment
|
||||
tsHost.concatMultipleLeadingComments = false;
|
||||
})
|
||||
// Configure jsdoc-style tag parsing
|
||||
.config(function(parseTagsProcessor, getInjectables, tsHost) {
|
||||
// Load up all the tag definitions in the tag-defs folder
|
||||
parseTagsProcessor.tagDefinitions = parseTagsProcessor.tagDefinitions.concat(
|
||||
getInjectables(requireFolder(__dirname, './tag-defs')));
|
||||
// We don't want license headers to be joined to the first API item's comment
|
||||
tsHost.concatMultipleLeadingComments = false;
|
||||
})
|
||||
|
||||
.config(function(computeStability, splitDescription, addNotYetDocumentedProperty, API_DOC_TYPES_TO_RENDER, API_DOC_TYPES) {
|
||||
computeStability.docTypes = API_DOC_TYPES_TO_RENDER;
|
||||
// Only split the description on the API docs
|
||||
splitDescription.docTypes = API_DOC_TYPES.concat(['package-content']);
|
||||
addNotYetDocumentedProperty.docTypes = API_DOC_TYPES;
|
||||
})
|
||||
.config(function(
|
||||
computeStability, splitDescription, addNotYetDocumentedProperty,
|
||||
API_DOC_TYPES_TO_RENDER, API_DOC_TYPES) {
|
||||
computeStability.docTypes = API_DOC_TYPES_TO_RENDER;
|
||||
// Only split the description on the API docs
|
||||
splitDescription.docTypes = API_DOC_TYPES.concat(['package-content']);
|
||||
addNotYetDocumentedProperty.docTypes = API_DOC_TYPES;
|
||||
})
|
||||
|
||||
.config(function(mergeDecoratorDocs) {
|
||||
mergeDecoratorDocs.propertiesToMerge = [
|
||||
'shortDescription',
|
||||
'description',
|
||||
'security',
|
||||
'deprecated',
|
||||
'see',
|
||||
'usageNotes',
|
||||
];
|
||||
})
|
||||
.config(function(mergeDecoratorDocs) {
|
||||
mergeDecoratorDocs.propertiesToMerge = [
|
||||
'shortDescription',
|
||||
'description',
|
||||
'security',
|
||||
'deprecated',
|
||||
'see',
|
||||
'usageNotes',
|
||||
];
|
||||
})
|
||||
|
||||
.config(function(checkContentRules, API_DOC_TYPES, API_CONTAINED_DOC_TYPES) {
|
||||
addMinLengthRules(checkContentRules);
|
||||
addHeadingRules(checkContentRules, API_DOC_TYPES);
|
||||
addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES);
|
||||
checkContentRules.failOnContentErrors = true;
|
||||
})
|
||||
.config(function(checkContentRules, API_DOC_TYPES, API_CONTAINED_DOC_TYPES) {
|
||||
addMinLengthRules(checkContentRules);
|
||||
addHeadingRules(checkContentRules, API_DOC_TYPES);
|
||||
addAllowedPropertiesRules(checkContentRules, API_CONTAINED_DOC_TYPES);
|
||||
checkContentRules.failOnContentErrors = true;
|
||||
})
|
||||
|
||||
.config(function(filterContainedDocs, API_CONTAINED_DOC_TYPES) {
|
||||
filterContainedDocs.docTypes = API_CONTAINED_DOC_TYPES;
|
||||
})
|
||||
.config(function(filterContainedDocs, API_CONTAINED_DOC_TYPES) {
|
||||
filterContainedDocs.docTypes = API_CONTAINED_DOC_TYPES;
|
||||
})
|
||||
|
||||
|
||||
.config(function(computePathsProcessor, EXPORT_DOC_TYPES, generateApiListDoc) {
|
||||
.config(function(computePathsProcessor, EXPORT_DOC_TYPES, generateApiListDoc) {
|
||||
|
||||
const API_SEGMENT = 'api';
|
||||
const API_SEGMENT = 'api';
|
||||
|
||||
generateApiListDoc.outputFolder = API_SEGMENT;
|
||||
generateApiListDoc.outputFolder = API_SEGMENT;
|
||||
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['package'],
|
||||
getPath: function computeModulePath(doc) {
|
||||
doc.moduleFolder = `${API_SEGMENT}/${doc.id.replace(/\/index$/, '')}`;
|
||||
return doc.moduleFolder;
|
||||
},
|
||||
outputPathTemplate: '${moduleFolder}.json'
|
||||
});
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe']),
|
||||
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
|
||||
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json',
|
||||
});
|
||||
})
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: ['package'],
|
||||
getPath: function computeModulePath(doc) {
|
||||
doc.moduleFolder = `${API_SEGMENT}/${doc.id.replace(/\/index$/, '')}`;
|
||||
return doc.moduleFolder;
|
||||
},
|
||||
outputPathTemplate: '${moduleFolder}.json'
|
||||
});
|
||||
computePathsProcessor.pathTemplates.push({
|
||||
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'ngmodule', 'pipe']),
|
||||
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
|
||||
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json',
|
||||
});
|
||||
})
|
||||
|
||||
.config(function(templateFinder) {
|
||||
// Where to find the templates for the API doc rendering
|
||||
templateFinder.templateFolders.unshift(API_TEMPLATES_PATH);
|
||||
})
|
||||
.config(function(templateFinder) {
|
||||
// Where to find the templates for the API doc rendering
|
||||
templateFinder.templateFolders.unshift(API_TEMPLATES_PATH);
|
||||
})
|
||||
|
||||
|
||||
.config(function(convertToJsonProcessor, postProcessHtml, API_DOC_TYPES_TO_RENDER, API_DOC_TYPES, autoLinkCode) {
|
||||
convertToJsonProcessor.docTypes = convertToJsonProcessor.docTypes.concat(API_DOC_TYPES_TO_RENDER);
|
||||
postProcessHtml.docTypes = convertToJsonProcessor.docTypes.concat(API_DOC_TYPES_TO_RENDER);
|
||||
autoLinkCode.docTypes = API_DOC_TYPES;
|
||||
autoLinkCode.codeElements = ['code', 'code-example', 'code-pane'];
|
||||
});
|
||||
.config(function(
|
||||
convertToJsonProcessor, postProcessHtml, API_DOC_TYPES_TO_RENDER, API_DOC_TYPES,
|
||||
autoLinkCode) {
|
||||
convertToJsonProcessor.docTypes =
|
||||
convertToJsonProcessor.docTypes.concat(API_DOC_TYPES_TO_RENDER);
|
||||
postProcessHtml.docTypes =
|
||||
convertToJsonProcessor.docTypes.concat(API_DOC_TYPES_TO_RENDER);
|
||||
autoLinkCode.docTypes = API_DOC_TYPES;
|
||||
autoLinkCode.codeElements = ['code', 'code-example', 'code-pane'];
|
||||
});
|
||||
|
||||
|
||||
function addMinLengthRules(checkContentRules) {
|
||||
|
Reference in New Issue
Block a user