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

[typedoc-plugin-markdown@next] Bug: Links to README.md in header broken in member pages. #483

Closed
sharky98 opened this issue Oct 20, 2023 · 2 comments
Labels
next Fix available in the '@next' release

Comments

@sharky98
Copy link

sharky98 commented Oct 20, 2023

Hello,

I have an issue where the links to the module README.md files are not relative from the member pages when building a doc for a monorepository ("entryPointStrategy": "packages", based on Gerrit0 example).

Version: 4.0.0-next.23(typedoc@0.25.1)

I am using the default outputFileStrategy (members).

For example, taking the tree shown in the option guide.

In the page ClassA.md, the header would uses [README](README.md) ∙ [API](../modules.md) for the links, correctly using the relative for the modules.md page, but not for the README.md page.

It is to note that the breadcrumbs do get relative links as expected, but they all point to the modules files, which already get its relative links correctly in the header.

[API](../../../modules.md) > [package-1](../modules.md) > Content

monorepo
├── README.md
├── modules.md
├── package-a
├── ├── README.md
├── ├── modules.md
│   ├── classes
│   │   ├── ClassA.md
│   │   ├── ClassB.md
├── ├── variables
│   │   ├── VariableA.md
│   │   ├── VariableB.md
├── package-b
├── ├── README.md
├── ├── modules.md
│   ├── classes
│   │   ├── ClassA.md
│   │   ├── ClassB.md
├── ├── variables
│   │   ├── VariableA.md
│   │   ├── VariableB.md

I was looking at the tests, and I'm not sure if I am reading this right, but it looks that this case is not covered. Seems that

  • Generation of the README.md themselves are checked.

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/3a0a5bea81b14857d387fbfba599200212634eeb/packages/typedoc-plugin-markdown/test/specs/__snapshots__/readmes.spec.ts.snap#L20-L48

  • Existing links are checked. However, here I only see the modules.md links, not the readme (under both package-1 and package-2, the URL is only for the modules.md and there is no README.md URLs.

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/3a0a5bea81b14857d387fbfba599200212634eeb/packages/typedoc-plugin-markdown/test/specs/__snapshots__/navigation.spec.ts.snap#L3-L44

  • Index page for a monorepo is checked.

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/3a0a5bea81b14857d387fbfba599200212634eeb/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap#L493-L509

  • Urls are checked, and shows that README.md files are detected.

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/3a0a5bea81b14857d387fbfba599200212634eeb/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap#L113-L124

  • When looking at the reflection tests, none seems to use the packages entry point strategy; but they do get relative URL to the README.md files.
@sharky98
Copy link
Author

sharky98 commented Oct 20, 2023

Could this be the culprit? 🧐

function packageHeader() not using context.relativeURL()

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/3a0a5bea81b14857d387fbfba599200212634eeb/packages/typedoc-plugin-markdown/src/theme/resources/partials/header.ts#L86-L88

Compared to function projectHeader() using context.relativeURL()

https://github.com/tgreyuk/typedoc-plugin-markdown/blob/3a0a5bea81b14857d387fbfba599200212634eeb/packages/typedoc-plugin-markdown/src/theme/resources/partials/header.ts#L51-L53

EDIT: I tried monkey patching it and it did create relative links, but to the root project README.md file, not the package README.md file.

EDIT 2: I trying to figure out some more using some console.log in that header.ts file. However, I was taken aback a bit. It seems that the package-a and package-b README.md and modules.md files are correctly created. However, that README.md file of the package seems to be absent from there. As such, when in package-a/classes/ClassA.md, the context consider monorepo as its parent package (in fact using the project term) and not package-a. I am lost from there. Will wait for your feedback! 🙃

EDIT 3: In any case, the markdown output is WAY better than the v3! 🎉✨ I love it!

@tgreyuk tgreyuk added the next Fix available in the '@next' release label Oct 20, 2023
@tgreyuk
Copy link
Member

tgreyuk commented Oct 20, 2023

Thanks for feedback and the detailed description is very much appreciated. You were on the right lines about including the relativeUrl method, but the url needed to include the package directory.

Fix in typedoc-plugin-markdown@4.0.0-next.24 .

@tgreyuk tgreyuk closed this as completed Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
next Fix available in the '@next' release
Projects
None yet
Development

No branches or pull requests

2 participants