Skip to content
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

Is there a built-in way to rename an entire module (i.e. customize its name so that it's not just the filename)? #2165

Closed
JL102 opened this issue Feb 8, 2023 · 5 comments
Labels
question Question about functionality
Milestone

Comments

@JL102
Copy link

JL102 commented Feb 8, 2023

Search terms

rename, module, file, namespace

Question

Hi,

I have a file mminit.ts which defines a bunch of variables on the Window object. The name mminit is quite cryptic, and I'd like to rename it something like Window or DOMExtensions. I have a comment with the tag /** @module DOMExtensions */ at the top of the file, but it does nothing.

Is there a way to make the file show up in the documentation with a custom name other than mminit?
I could probably jury-rig it with a janky solution via a plugin, but I'd like to see if there's a built-in way first. I can't find anything in the documentation that seems to work, though.

@JL102 JL102 added the question Question about functionality label Feb 8, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Feb 9, 2023

I have a comment with the tag /** @module DOMExtensions */ at the top of the file, but it does nothing.

This is the way to go - is the comment the very first thing in the file, before any imports? It should do what you've described you want.

@Gerrit0 Gerrit0 closed this as completed Feb 26, 2023
@JL102
Copy link
Author

JL102 commented Apr 17, 2023

@Gerrit0 Apologies for missing your reply. It took me a while to get back to this.

I just checked putting /** @module <module name> */ at the top of one of our project's ESM files and it did work, but unfortunately mminit is one of the few files which are actually global scope; and it looks like the @module trick doesn't work for globally scoped scripts.

It is dawning on me now why that is the case - since it being global scope by definition makes it not a module. That being said, it would still be helpful to rename all the scripts from that file, because having mminit in the list of modules in our api docs is extremely unclear. Is there a potential workaround?

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 17, 2023

Hmm, yeah, global files are a problem. They don't get a symbol, so comment discovery doesn't find any comments for them. They're the only thing reflection like this... there's probably a not completely terrible way of discovering comments for "global modules"...

Gerrit0 added a commit that referenced this issue Apr 21, 2023
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 21, 2023

I was right, that wasn't bad at all, 20 minutes, will be available in the next release :)

@Gerrit0 Gerrit0 added this to the v0.24.5 milestone Apr 21, 2023
@JL102
Copy link
Author

JL102 commented Apr 28, 2023

I was right, that wasn't bad at all, 20 minutes, will be available in the next release :)

Sweet, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question about functionality
Projects
None yet
Development

No branches or pull requests

2 participants