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
Document namespaces created from ES2015 modules #1504
Comments
You can do this today by putting the comment at the top of the file in foo.ts with an I kind of like being able to put the comment on the export - but that causes other problems: /** which export does this comment belong to? */
export { x, y } from "./foo" |
Isn't In JS/ES/TS there is no concept called "package", it's something that package managers (e.g. NPM) have introduced to the ecosystem. So having the tag for documenting modules be called TSDoc has the following to say about
Therefore I would argue that namespaces generated by JS'/ES'/TS' module system are API items and should not be documented using this tag. I know that TypeDoc doesn't adhere to TSDoc (yet), so this should only be seen as a second opinion. I also want to say that documenting modules/files isn't what I want to do. I don't want to document the module itself, I want to document the namespace created to export that module. The namespace I care about is created with the
The reason why your example isn't a problem is that it doesn't create a new namespace. It just creates (and exports) a few variables. |
That's a fair point - when I added that behavior a couple years ago I was treating packages and modules as essentially the same thing, and looking for some way to disambiguate comments at the start of files (we can't just take the first comment because that's a license comment in some projects... or at least that's been the argument in the past, I've always been on the fence about caring about those projects... just stick a license file in your project root!) I'm open to changing this behavior.
True - that was somewhat of a bad example - here we introduce a new name for an export, which we might reasonably want to have a comment for... I don't necessarily like requiring users to introduce a second export line just to document it: export { createElement, createElement as h } from "./jsx" The new namespace issue is tricky since, in order to document it, we have to resolve the symbol aliases to get to the SourceFile that is used as a namespace... there isn't a great way to get comments after resolving the symbol... I don't really want to add a second "commentSymbol" to |
I see. In that case, it's better to keep the current solution of documenting modules themselves.
How about we use the Usage will look like this: /**
* Some module documentation + renaming.
* @module foo
*/ /**
* Some module documentation, no renaming.
* @module
*/ This is also how JSDoc documents modules. |
Tricky != bad idea. After thinking about it for a while, I went ahead and made the necessary changes, incurred a bit of tech debt that should be fixed with 0.21. Version 0.20.25 will let you specify comments on export declarations, and if an export declaration has a comment, it will override any comment specified for the child node. It also adds support for |
Thank you @Gerrit0! I have a question regarding the overriding behaviour: Is there a way to view the overridden module comment or will it be discarded/not be present in the generated site? |
It depends. If that module is only accessible from the re-export that has an overriding comment, then no, it won't be included anywhere. If the module is documented more than once (with the module being an entry point or a second re-export not having an overriding comment), then the comment in the module will be used. |
I see. I don't know if it's a good idea to discard the module doc but I also don't have a way of cleverly combining them. As long as this behaviour is clearly communicated on the website, it's ok I guess. |
Coming back to this months later... my answer has changed somewhat. Supporting |
Removed typedoc-plugin-typescript-declaration because the functionality seems to be included into typedoc from version 0.20.25 on. Related line from typdoc [changelog](https://typedoc.org/changelog/) - Support for specifying comments on export declarations [(7b7bf66)](TypeStrong/typedoc@7b7bf66), closes [#1504](TypeStrong/typedoc#1504) This fix the security issue with using a dependency to a old marked package version. [CVE-2021-21306](https://nvd.nist.gov/vuln/detail/CVE-2021-21306)
Hi, can this @module tag be used to rename the |
Search Terms
ES2015 modules, import, export
Problem
It's not possible to add a description to namespaces that were created using ES2015 modules.
Example:
Suggested Solution
Since the namespace is created by
export * as namespace
, the namespace should be documented there as well.Example:
The text was updated successfully, but these errors were encountered: