-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
doc: anchor link parity between markdown and html-generated docs #39304
Conversation
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for putting the effort into this, that's good work! I am a bit concerned regarding breaking existing links, but maybe the upside is worth the potential breaking. Maybe we could add something similar to what we did at https://nodejs.org/docs/latest/api/modules.html#modules_module_builtinmodules?
Alternatively, have you looked into https://www.markdownguide.org/extended-syntax/#heading-ids as an alternative? If GitHub web UI supports those, that would let us keep our existing links for the same benefit – the downside would be to have to add those heading-ids in our .md
files.
That was the first thing I tried :) Unfortunately it's not supported in the Github markdown renderer, it just renders it next to the heading.
I think I have a solution: 24df945 adds alias anchors to each heading that reflect the old ID scheme, while keeping the markdown uncluttered. I think that should preserve all incoming links! Let me know if you think the HTML should be different. |
24df945
to
6d3f460
Compare
f58ccf2
to
50b726f
Compare
af39af5
to
f39d7b7
Compare
125c287
to
301ff47
Compare
@nodejs/documentation wdyt? |
848b7e5
to
b300764
Compare
b300764
to
849213e
Compare
I've added the |
849213e
to
a15f6a2
Compare
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: #39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Landed in 6fdd582. |
Thanks again for your hard work on this. Would you like to open a backport PR for v14.x? The commands to achieve that would be: git fetch upstream master
git fetch upstream v14.x-staging
git reset upstream/v14.x-staging --hard
git cherry-pick 6fdd5827f0956ffc4e7ffe31babaf530e42f75b9 |
Awesome!
I'd love to. |
Please don't backport yet. It would introduce massive conflicts with commits that haven't landed yet on v14.x |
I expect there to be some big conflicts - I don't mind working through them - but happy to wait for your go-ahead before submitting the backport PR, @targos. Let me know. |
@targos any change? is there still a desire to have this backported? |
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: #39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
There were little conflicts on v16.x-staging and I fixed them. Pushed at d3f3111 |
About v14.x, I would be happy to review a backport pull request, but the branch is going into maintenance in less than two weeks, so maybe it's not worth the work. |
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: #39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: nodejs#39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: nodejs#39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: nodejs#39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Main changes: - Replace current HTML anchor generation to match header anchor generation in Github markdown. - Remove unnecessary double namespacing on generated anchors/links (E.G. `esm.md#loaders` instead of `esm.md#esm_loaders`). - Anchors/links are automatically prefixed with their respective modules when concatenated for usage in `all.html`. Benefits: - All anchor links within and between markdown API docs actually work. - Adding new anchor links no longer requires contributors to generate the HTML docs first to look up the correct anchors. - Anchors are much shorter. - All previous anchor links are preserved by generating hidden legacy anchors. PR-URL: nodejs#39304 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Thank you for merging into 16.x, hope it wasn't too cumbersome! 🙌🏽 I've submitted a PR for the backport at #40495 , hopefully I'm not too late. |
Inspired by @aduh95's comments on #39164.
Honestly, this is probably a long shot due to the amount of changes, but I think the benefits are substantial - so here goes.
Main Changes
esm.md#loaders
instead ofesm.md#esm_loaders
)all.html
Benefits
Linting (
make lint-md
) and doc generation (make doc-only
) should have verified all new links are correct, so hopefully that saves you from needing to double-check 95% of changes in this PR. The most important changes are to files intools/doc
.I realize this will mean tons of rebasing if this PR stays open, but I don't mind doing it if there's a chance links in the markdown docs might actually work at some point.
Other issues that discuss this: #35189 (specific comment)