-
Notifications
You must be signed in to change notification settings - Fork 24.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
build(docs-infra): support hiding constructors of injectable classes #24529
build(docs-infra): support hiding constructors of injectable classes #24529
Conversation
You can preview aca3297 at https://pr24529-aca3297.ngbuilds.io/. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You might want to also update overview-dump.template.html.
On second thought, I find the tag name a little confusing. Maybe something more assertive, like |
How about even more descriptive and specific:
What do you think? |
If it is true that all |
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.
aca3297
to
2a76143
Compare
I rewrote this PR so you don't need to annotate the class constructor to make it hidden. I also noticed that |
@gkalpak PTAL due to the complete rewrite |
expect(processor.$runBefore).toEqual(['docs-processed']); | ||
}); | ||
|
||
it('should remove undocumented constructors from docs that have an "Injectable" decorator on it', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it --> them 😇
const injector = dgeni.configureInjector(); | ||
const processor = injector.get('removeInjectableConstructors'); | ||
expect(processor.$process).toBeDefined(); | ||
expect(processor.$runAfter).toEqual(['processing-docs']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be ['processing-docs', 'splitDescription']
?
return { | ||
$runAfter: ['processing-docs', 'splitDescription'], | ||
$runBefore: ['docs-processed'], | ||
injectableDecorators: ['Injectable', 'Directive', 'Component', 'Pipe'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about NgModule
?
docs.forEach(doc => { | ||
if ( | ||
doc.constructorDoc && | ||
!doc.constructorDoc.shortDescription && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can a constructorDoc
have a description
but no shortDescription
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not if it runs after the splitDescription
processor.
This solution makes the doc writer responsible for NOT including a doc comment (or including an empty one) on the constructor for a service. Is that what you want? If so, I will add it to the guidelines. An explicit tag would have the advantage of showing that the choice not to document is explicit, and not a side-effect of incomplete documentation. |
Actually they could still add an explicit tag, e.g.
As it stands we would not fail if this were missing but perhaps it could become enforceable later. |
You can preview a4fed6c at https://pr24529-a4fed6c.ngbuilds.io/. |
I like that with the boilerplate -- it would make people think about what they are doing, and provide an explanation for users who are looking at the code. |
You can preview 4feac28 at https://pr24529-4feac28.ngbuilds.io/. |
…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
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Class 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.