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
28
aio/tools/transforms/angular-api-package/processors/addGlobalApiData.js
vendored
Normal file
28
aio/tools/transforms/angular-api-package/processors/addGlobalApiData.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* @dgProcessor addGlobalApiData
|
||||
*
|
||||
* Marks APIs tagged with `@globalApi` as globals and
|
||||
* prefixes them with the namespace, if there is one.
|
||||
*/
|
||||
module.exports = function addGlobalApiDataProcessor() {
|
||||
return {
|
||||
$runBefore: ['computing-ids'],
|
||||
$process: function(docs) {
|
||||
docs.forEach(doc => {
|
||||
const globalApiTag = doc.globalApi && doc.globalApi.trim();
|
||||
|
||||
if (globalApiTag != null) {
|
||||
doc.global = true;
|
||||
|
||||
if (globalApiTag.length > 0) {
|
||||
// Prefix the symbol name with the global namespace,
|
||||
// if we have one (e.g. `foo` becomes `ng.foo`).
|
||||
doc.unprefixedName = doc.name;
|
||||
doc.name = `${globalApiTag}.${doc.name}`;
|
||||
doc.globalNamespace = globalApiTag;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
};
|
Reference in New Issue
Block a user