typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
725 stars 177 forks source link

Remove superfluous words in breadcrumbs + markdown title #693

Open Zamiell opened 1 month ago

Zamiell commented 1 month ago

What package is the feature request related to?

typedoc-plugin-markdown

Background

Hello! I am using the outputFileStrategy: "modules" in order to get the typedoc-plugin-markdown to make one Markdown page per module/category, but I am not sure that it is relevant to the request. (I am including it just in case.)

My request is that currently, my Markdown output looks like this:

image

I don't really like this format, because there is some unnecessary repetition. Specifically, I would prefer that this:

complete-common > functions > functions/array

is changed to this:

complete-common > functions > array

Is that something that can be considered?

(Note that I would like the superfluous words (i.e. "function") removed from both the breadcrumb section and the markdown title itself.)

Zamiell commented 1 month ago

I'll add that this kind of thing makes the Docusaurus sidebar pretty ugly too. Here's an example of what my sidebar looks like:

image

I think it would be a lot cleaner without the "function/" and "type/" prefixes.

tgreyuk commented 1 month ago

Hi,

functions/array is the name typedoc has internally assigned to the module and this plugin does not change it. You can configure this with the @module tag - https://typedoc.org/tags/module/ , or edit your entrypoints https://typedoc.org/options/input/#entrypoints.

As for the sidebar, this pick up whatever the module name is.

Hope this helps a bit. If your repo is public i could probably advise further.

Zamiell commented 1 month ago

Thanks for the quick reply. I think I see the problem, it is because I am using outputFileStrategy: "modules", and then providing each individual file as an entry point. I am doing this because I want my functions to be sorted into categories, like "array functions", "set functions", and so on.

It would be annoying to manually set a @module in every single file, because then if e.g. I rename foo.ts to bar.ts, then I would also have to update @module foo to @module bar, so there is a danger of getting out of sync (and this violates DRY).

Do you know if there is a better solution?

If your repo is public i could probably advise further.

It is indeed public, you can find my docs here:

tgreyuk commented 1 month ago

Do you know if there is a better solution?

Having reviewed this I don't think this is currently achievable, but there is certainly a good use-case for it.

I think a new option is required that would ignore the full module path in the titles . Something like flattenModuleTitles or excludePathsInModuleTitles might work when module names are resolved in this way.

I'll add that this kind of thing makes the Docusaurus sidebar pretty ugly too.

As for the sidebar, if you build with the docusaurus plugin it actually writes a sidebar file structure with correct names, that can then be consumed in sidebars.ts https://www.typedoc-plugin-markdown.org/plugins/docusaurus/sidebar. If you want to run typedoc independently the docusaurus plugin also exposes a cli command docusaurus generate-typedoc.