typedoc-plugin-markdown
typedoc-plugin-markdown copied to clipboard
Remove superfluous words in breadcrumbs + markdown title
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:
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.)
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:
I think it would be a lot cleaner without the "function/" and "type/" prefixes.
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.
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:
- https://complete-ts.github.io/ (the Docusaurus website)
- https://github.com/complete-ts/complete (the monorepo)
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.
Hello again :)
It seems you have come up with a reasonable workaround solution to this already, but as of [email protected] you can now parse the module titles in a js config:
pageTitleTemplates: {
// parse the module name to something else
module: (args) => args.name,
}
It won't actually change the internal module name, but might help your use case.