Restore class names of default-exported modules #39
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.
This is an attempt to resolve the downstream issue I just filed, jsdoc2md/jsdoc-to-markdown#270 - see that issue for more details, but the short is, if we're parsing the following file:
Then we'll currently generate entries for the class and the constructor under
module.exports
because of how ES6 rewrites things internally. This uses the module name for the exported class and constructor instead, which is more in line with what end-users expect. There's an existing workaround with@alias
forjsdoc-to-markdown
, but it seems to me like just that - a suboptimal workaround.That said, I'm not sure that this is the correct level to implement this remapping at - I don't know if this library is used widely outside of
jsdoc-to-markdown
, and if this would qualify as a breaking change. I looked into fixing it up injsdoc-to-markdown
, but since the results ofjsdoc-parse
are basically piped directly intodmd
, it looked like it would require either elaborate template conditions, or a remapping similar to this, added to a pipeline that currently doesn't do any transformation of the result fromjsdoc-parse
.But if this is a reasonable approach that's just not in the right place, it's a pretty simple transform, so it wouldn't be difficult to add into the pipeline in
jsdoc-to-markdown
.Also the conditions I used for rewriting seem pretty conservative to me, but I'm not super familiar with the problem space here, so I don't know if there's a possibility of affecting other use cases.