Logo
Explore Help
Sign In
iSharkFly-Docs/angular-docs-cn
1
0
Fork 0
You've already forked angular-docs-cn
Code Issues Pull Requests Packages Projects Releases Wiki Activity
angular-docs-cn/aio/tools/transforms/angular-api-package/processors/removeInjectableConstructors.js

19 lines
597 B
JavaScript
Raw Normal View History

build(docs-infra): support hiding constructors of injectable classes (#24529) Classes that are injectable often have constructors that should not be called by the application developer. It is the responsibility of the injector to instantiate the class and the constructor often contains private implementation details that may need to change. This commit removes constructors from the docs for API items that are both: a) Marked with an injectable decorator (e.g. Injectable, Directive, Component, Pipe), and b) Have no constructor description This second rule allows the developer to override the removal if there is something useful to say about the constructor. Note that "normal" classes such as `angimations/HttpHeaders` do not have their constructor removed, despite (at this time) having no description. PR Close #24529
2018-06-14 23:51:34 +01:00
module.exports = function removeInjectableConstructors() {
return {
$runAfter: ['processing-docs', 'splitDescription'],
$runBefore: ['docs-processed'],
injectableDecorators: ['Injectable', 'Directive', 'Component', 'Pipe', 'NgModule'],
$process(docs) {
docs.forEach(doc => {
if (
doc.constructorDoc &&
!doc.constructorDoc.shortDescription &&
doc.decorators &&
doc.decorators.some(decorator => this.injectableDecorators.indexOf(decorator.name) !== -1)) {
delete doc.constructorDoc;
}
});
}
};
};
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.23.1 Page: 302ms Template: 2ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API