-
Notifications
You must be signed in to change notification settings - Fork 30k
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: add dynamic source code links #33996
Conversation
Welcome, @aw-davidson, and thanks for the pull request. What's the reason for wanting this? I see at least one problem with this, but it may be outweighed by a benefit if this solves problems for people. The problem I see is that when these are rendered to HTML docs, it will mean that documentation for a specific version of Node.js will always link to the current master branch which can have very big differences.. I don't think that's what we want, but I don't know that there's an easy better solution either. |
@Trott, I thought it would be nice to add some visibility to the source code. Documentation for python and go have similar links to source code. I do see the issue with linking to master branch. Maybe something dynamic can be done here? https://github.com/nodejs/node/blob/master/tools/doc/html.js |
What if there was a comment in the markdown like that is replaced with an inline link at build time. And the inline link would link to a version branch. For example: https://github.com/nodejs/node/blob/v14.1.0/lib/buffer.js |
If you're up for implementing something like that, I think that would be great. |
e5af67b
to
6b8796d
Compare
@Trott, I made changes to dynamically link to the right version of the source code. You can now link to code with a comment in the markdown: |
@@ -82,7 +82,7 @@ async function main() { | |||
const content = await unified() | |||
.use(replaceLinks, { filename, linksMapper }) | |||
.use(markdown) | |||
.use(html.preprocessText) | |||
.use(html.preprocessText, { nodeVersion }) |
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.
Can you undo the mode change for this file?
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.
Yeah, did not mean to commit that. I think I just changed it back.
6b8796d
to
3d3c43e
Compare
@nodejs/documentation @nodejs/website |
3d3c43e
to
972c47d
Compare
I added links for all appropriate modules. Is it possible to retrigger the job that failed? I don't believe the failures would be related to my changes. |
Failure from https://github.com/nodejs/node/pull/33996/checks?check_run_id=804738177 is
I suspect the test will need to be updated. |
972c47d
to
3a77126
Compare
@richardlau, thanks for pointing that out. I just updated the one test that was failing and it looks like all the checks are good now. |
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.
I have some small changes I'd prefer, but rather than nit pick on this, I'll say "LGTM" and plan to do some modifications myself later (or not--they're not necessary, just my preference).
This will result in broken links when built on the master branch, but I'm not sure that's really a problem. But if there's an easy fix, let's fix it.... |
For example, I just built it on master and one of the links is https://github.com/nodejs/node/blob/v15.0.0/lib/assert.js. That will exist some day but...not right now. |
Maybe someone from @nodejs/releasers can indicate if they think this is A+ compatible with the release process or not. (I think it should work fine. Looping in releasers just in case there's something interesting about when/how the version vX.XX tags are set and how it relates to nodeVersion/ |
Lines 747 to 749 in 122038c
Lines 51 to 52 in e68563e
As far as the release process goes, the release tag is pushed the step before the release is promoted (i.e. made live on the website) so actual releases should be okay: https://github.com/nodejs/node/blob/master/doc/guides/releases.md#14-push-the-release-tag Anything built from master or a -staging branch though is going to point to a does-not-exist yet version. Wild (untested) idea could be to look for the version passed into the doctool in the changelog (for a release a changelog entry will be created) and if the version isn't in the changelog redirect to a staging branch (if the major is in the changelog) or master (if the major doesn't exist in the changelog). |
Thanks @Trott and @richardlau for guiding me through my first commit. I'm also happy to work on this more if you have any ideas / improvements. |
Thanks for the contribution! richardlau's idea here is probably worth experimenting with to see if it would work as an enhancement:
|
Checklist