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

[Website Generator] Links must be .html for nodejs.org/api but they're actually .md on github #28689

Closed
srcmake opened this issue Jul 15, 2019 · 10 comments
Labels
doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.

Comments

@srcmake
Copy link
Contributor

srcmake commented Jul 15, 2019

The doc/api folder is full of .md files that serve as the documentation for the Node.js JavaScript libraries. These files are also what's used in the nodejs.org website for the website's api documentation.

Evidently, there's a tool that converts these .md files into the doc folder into the webpages on nodejs.org. (And I think that tool gets run as part of the Release process for each Node.js version bump. I'm not 100% sure about that, though.)

The issue is that URLs in the doc files that link to other doc files must be formatted with a .html extension to work properly for the website. For example, this PR that tries to change .html extensions to .md can't be merged because it would break the nodejs.org api documentation.

This is a problem because on github, the links don't work properly because the file names on github have .md extensions, not .html. Which means that links on github in those files don't work because the file being referenced (ex. doc-name.html) doesn't exist.

The solution would be to update the website api doc generation tool (which I think is this) to convert any .md extensions in URLs to .html when going through the doc files, so that we can update URLs in those docs to be .md so that they link correctly to the actual files on github.

@Trott
Copy link
Member

Trott commented Jul 15, 2019

The solution would be to update the website api doc generation tool (which I think is this) to convert any .md extensions in URLs to .html when going through the doc files, so that we can update URLs in those docs to be .md so that they link correctly to the actual files on github.

There's a wrinkle because there are .md links that should be kept as .md links. If it's a link to elsewhere within the API docs, then it should be changed to .html. Otherwise, it should not be changed. For example, in the os.md file, there is a link to our BUILDING.md file. That should not be changed. Similarly, documentation.md contains a link to our CONTRIBUTING.md file that should also not be changed.

@Trott Trott added doc Issues and PRs related to the documentations. good first issue Issues that are suitable for first-time contributors. labels Jul 15, 2019
@Trott
Copy link
Member

Trott commented Jul 15, 2019

/ping @rubys although I don't think they're doing much on the project these days.

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Jul 15, 2019

It is also more than just extensions. The #hash parts of the links are also different. Compare the GitHub-tools-generated heading anchors in .md and Node.js-tools-generated heading anchors in .html:

https://github.com/nodejs/node/blob/master/doc/api/buffer.md#class-buffer
https://nodejs.org/api/buffer.html#buffer_class_buffer

@grapheo12
Copy link

Hello! Is this still open? I would like to work on it.

@srcmake
Copy link
Contributor Author

srcmake commented Jul 28, 2019

@grapheo12 As far as I know, it's still open.

@grapheo12
Copy link

So what do I do? Make something that parses each and every .md file in the doc/api folder and convert any .md link to corresponding .html link.
Additionally, I would also maintain an exception list for those files that @Trott mentioned.
Please reply if I am going in the right direction.

@srcmake
Copy link
Contributor Author

srcmake commented Jul 29, 2019

@grapheo12 Well. The idea is to update the existing scripts that generate the Node API documentation website (linked above) to convert any .md links (where appropriate) to be .html. So if the script sees a reference to "async-hooks.md", the script will realize "oh, that file is going to end up being an HTML file for the website. I should just pretend the link is "async-hooks.html" instead.

After that happens, we can change any .html links in the api folder to .md so that they can work on github.

The exact implementation of the first step depends on how the website generation tool works.

@Trott Trott added help wanted Issues that need assistance from volunteers or PRs that need help to proceed. and removed good first issue Issues that are suitable for first-time contributors. labels Jul 30, 2019
@akash-joshi
Copy link

Which website generation tool is used ? Would like to pick this issue up

@vsemozhetbyt
Copy link
Contributor

@akash-joshi Scripts that convert .md files into .html files are placed in tools/doc folder. How they are launched, see in Makefile (search for doc or generate.js).

@MarekLabuz
Copy link

Hello everyone, I came up with an idea how to solve this issue. I’ve noticed that docs markdown files are created in a way, that links references are located at the end of a file.

synopsis.md

(...)

[Command Line Options]: cli.html#cli_command_line_options
[this guide]: https://nodejs.org/en/download/package-manager/
[web server]: http.html

Instead of creating a seperate file, that maps between *.md and *.html, I suggest transforming markdown files according to the example:

synopsis.md

(...)

[Command Line Options]: cli.md#command_line_options
[this guide]: https://nodejs.org/en/download/package-manager/
[web server]: http.md

[Command Line Options `.html`]: cli.html#cli_command_line_options
[web server `.html`]: http.html

Currently, process that transforms docs from markdown to html goes through several stages. I created a solution that consists in an additional stage applied at the beginning of this process. It replaces links references to their "`.html` version". The replacement is done in memory, so only output html files gain new urls and no content of actual files is changed. Output markdown files remove unused "`.html` versions" of links references. Additionally, the replacement happens only if the "`.html` version" of a link reference exists, it allows for gradual update of documentation without breaking it.

Trott pushed a commit to MarekLabuz/node that referenced this issue Nov 6, 2019
This commit introduces additional stage in the process of generating
html docs from markdown files. Plugin transforms links to *.md files
in the respository to links to *.html files in the online documentation.

Fixes: nodejs#28689
addaleax pushed a commit that referenced this issue Nov 30, 2019
This commit introduces additional stage in the process of generating
html docs from markdown files. Plugin transforms links to *.md files
in the respository to links to *.html files in the online documentation.

Fixes: #28689

PR-URL: #29946
Reviewed-By: Anna Henningsen <anna@addaleax.net>
targos pushed a commit that referenced this issue Dec 5, 2019
This commit introduces additional stage in the process of generating
html docs from markdown files. Plugin transforms links to *.md files
in the respository to links to *.html files in the online documentation.

Fixes: #28689

PR-URL: #29946
Reviewed-By: Anna Henningsen <anna@addaleax.net>
MylesBorins pushed a commit that referenced this issue Dec 17, 2019
This commit introduces additional stage in the process of generating
html docs from markdown files. Plugin transforms links to *.md files
in the respository to links to *.html files in the online documentation.

Fixes: #28689

PR-URL: #29946
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Issues and PRs related to the documentations. help wanted Issues that need assistance from volunteers or PRs that need help to proceed.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants