feat(docs-infra): add the ability to expose globals (#34237)
Adds the ability to expose global symbols in the API docs via the `@globalApi` tag. Also supports optionally setting a namespace which will be added to the name automatically (e.g. `foo` will be renamed to `ng.foo`). Relevant APIs should also be exported through the `global.ts` file which will show up under `core/global`. PR Close #34237
This commit is contained in:

committed by
Andrew Kushnir

parent
7a6e326ec6
commit
e7cf1e0580
26
aio/tools/transforms/angular-api-package/processors/updateGlobalApiPath.js
vendored
Normal file
26
aio/tools/transforms/angular-api-package/processors/updateGlobalApiPath.js
vendored
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* @dgProcessor updateGlobalApiPath
|
||||
*
|
||||
* If a global API has a namespace, its name will contain a dot which will cause its
|
||||
* URL to look like a file path. This processor updates it so it's less ambiguous.
|
||||
*/
|
||||
module.exports = function updateGlobalApiPathProcessor() {
|
||||
return {
|
||||
$runAfter: ['computePathsProcessor'],
|
||||
$runBefore: ['processNgModuleDocs'],
|
||||
$process: function(docs) {
|
||||
docs.forEach(doc => {
|
||||
if (doc.global && doc.globalNamespace) {
|
||||
// We need to change the path to camel case, because having a dot
|
||||
// in the URL will make it look like a file path.
|
||||
const name = doc.unprefixedName;
|
||||
const fileName = doc.globalNamespace + name[0].toUpperCase() + name.slice(1);
|
||||
|
||||
doc.path = `${doc.moduleDoc.moduleFolder}/${fileName}`;
|
||||
doc.outputPath =
|
||||
`${doc.moduleDoc.moduleFolder}/${fileName}.json`;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user