krisztianb / typedoc-plugin-merge-modules

Plugin for TypeDoc that merges the content of modules
ISC License
21 stars 4 forks source link

Should this plugin also replace "default" with the field name? #1

Closed felipecrs closed 3 years ago

felipecrs commented 3 years ago

First of all: your plugin saved my life. Thank you so much!

This started at https://github.com/TypeStrong/typedoc/issues/1521. So, now that all modules are merged, I think it does not make sense anymore to use "default" as the fieldname.

So, my point here is: should this plugin also replace "default" with the field name? I'm not asking to do, just discussing :).

image

felipecrs commented 3 years ago

PS: this makes the API not browsable, as only one "default" link works.

krisztianb commented 3 years ago

Hi Felipe. I'm glad the plugin is useful for somebody.

If you look at the code you will see that the plugin does nothing fancy. It only moves all reflections from the modules into the project.

So the answer to your question is: No, it should not rename any exports at the moment. Naming collisions are not handled. I can have a look at that though.

What would be your expected output?

felipecrs commented 3 years ago

No, it should not rename any exports at the moment. Naming collisions are not handled.

I thought more about it, and I agree, you're right. Especially because users may want to do the "renaming" without using your plugin together, so it would be better to be a standalone plugin.

What would be your expected output?

With TypeDoc 0.19 and --mode files, this is what I had:

image

Now, with TypeDoc 0.20 and your plugin:

image

Without your plugin:

image

(despite the bad naming, they at least don't overlap)

PS: I'm using docusaurus, but I already tested and this behavior remains in vanilla TypeDoc html generator.

krisztianb commented 3 years ago

That would mean that moving the reflections to the project somehow destroys their "path". I'll take a look when I find the time. This should by fairly easy to reproduce with a simple example.

felipecrs commented 3 years ago

If you want, you can try with my repository:

https://github.com/felipecrs/megatar/tree/upgrade-typedoc/website https://gitpod.io/#https://github.com/felipecrs/megatar/tree/upgrade-typedoc/website

felipecrs commented 3 years ago

@krisztianb fyi https://github.com/felipecrs/typedoc-plugin-rename-defaults

krisztianb commented 3 years ago

Interesting. Thanks for the heads up. I was thinking about adding an option (something like renameDefaults: true|false) to this plugin so that you don't need to create a separate one, since when merging modules this can be a common problem.

felipecrs commented 3 years ago

The main motivation for having a separate plugin is to be able to use it without your plugin.

felipecrs commented 3 years ago

I mean, for those who would still like to have their defaults renamed but they don't want to merge the modules. But the code itself is quite easy, as proposed by Gerrit0 at https://github.com/TypeStrong/typedoc/issues/1521#issuecomment-791971444.

felipecrs commented 3 years ago

I thought in these options:

krisztianb commented 3 years ago

I think renameDefaults: true makes a lot of sense. I don't think anybody wants to have something called default and moreover risk overwriting reflections when merging modules. I think I can add this option sometime next week.

krisztianb commented 3 years ago

New option mergeModulesRenameDefaults added in version 2.0.0. 🎉