feat(inheritDoc): Add support for copying item’s documentation by copying it from another API item #1468
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello! Thanks for your work, I really appreciate it.
Recently our team started to use Typedoc and we've come to the conclusion that we really do miss the support for
@inheritDoc
, which I believe is not currently implemented (see open issue #304) when we talk about inheriting from unrelated entities which is allowed in TSDoc, so I hope I can do something to make this feature a bit close.I've prepared a really quick PoC and a demo
Demo for this snippet is here: https://dergash.github.io/typedoc/modules.html#targetfunction
When preparing this PoC I've come to some questions which I hope we can discuss before going further.
So this draft is majorly based around ImplementsPlugin which I believe contains initial but undocumented support for TSDoc/inheritDoc.
My understanding is that when some class implements an interface, methods from that interface can inherit some parts of documentation (shortText, text,
@returns
and any tags which TypeDocs leaves without processing), to enable this featureinheritDoc
must be specified:Apparently it works. Docs will not be inherited without the tag.
So thinking about the differences between this implementation and the one expected in #304 / TSDoc:
Shoud current behavior of
ImplementsPlugin
be documented?Missing curly brackets
Apparently TSDoc treats
inhericDoc
as aninline tag
, hence they wrap it in curly bracers:ImplementsPlugin
(andInheritDocPlugin
from my PoC) are expecting no curly braces; the only tags moment stored in MarkedLinksPlugin and probably MarkedPluginWhat gets copied
According to TSDoc page following things are copied:
@remarks
block@params
blocks@typeParam
blocks@returns
blocksummary
and@remarks
confused me a bit; after reading both TSDoc and Typedoc docs I believe TSDocsummary
equals to Typedoc shortText, but I might be wrong: Typedoc emphasize on shortText "being the first paragraph of text" and thetext
is the rest of the comment, while from TSDoc description and API Exractor Overview I've got the impression that summary is all text until the first block tag.So it probably works like this: Typedoc takes first paragraph into
shortText
and the rest of the text totext
, when TSDoc tooks short text tosummary
and rest of the text shoul be inremarks
tag.So at the moment either
summary
and@remarks
are already copied as per TSDoc, or they don't and can't be copied due to inconsistency in comment structure.@params
and@typeParams
are not copied, but according to the TSDoc the should be.@returns
is copied.Custom tags which are not processed by Typedoc are copied.
Should this be implemented both for inheritDoc and implements plugin?
How exactly copying should be implemented?
At the moment inherited values override matching values on the target entity. Which seems consistent with JSDoc where
@inheritDoc
leads to ignoring all other tags. From TSDoc site and github I didn't quite get if it's override or merge. But if it is indeed override then@inheritDoc
won't work for #304 where there is a need to inherit a comment by concating it with existing comment.If this is the case, will you consider support for
@copyDoc
?