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

doc: Broken (404ing) links in Docs #26074

Closed
bnb opened this issue Feb 13, 2019 · 4 comments
Closed

doc: Broken (404ing) links in Docs #26074

bnb opened this issue Feb 13, 2019 · 4 comments
Labels
doc Issues and PRs related to the documentations.

Comments

@bnb
Copy link
Contributor

bnb commented Feb 13, 2019

Thanks to @JustinBeckwith's linkinator tool, I was able to pretty easily check our docs to see if any of the links were 404ing. Turns out we currently have 2 404s somewhere in the docs. Here are the links that are 404ing:

At a bare minimum, you could view source on docs/api/all.html and search for these links to identify where they are in the docs.

The tool currently falsely reports all DevTools protocol links as 404ing when they are not actually 404ing. I'll open up an issue on the linkinator repo for that.

@ofrobots ofrobots added the doc Issues and PRs related to the documentations. label Feb 14, 2019
@gengjiawen
Copy link
Member

http://man7.org/linux/man-pages/man1/curl.1.html this link is in this page https://nodejs.org/api/repl.html, The link is not in the repl.md, maybe we have a bug in generating the html.
image

@vsemozhetbyt
Copy link
Contributor

The generation takes place here:

node/tools/doc/html.js

Lines 125 to 142 in 6f64cda

// Handle references to man pages, eg "open(2)" or "lchmod(2)".
// Returns modified text, with such refs replaced with HTML links, for example
// '<a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>'.
function linkManPages(text) {
return text.replace(
MAN_PAGE, (match, beginning, name, number, optionalCharacter) => {
// Name consists of lowercase letters,
// number is a single digit with an optional lowercase letter.
const displayAs = `<code>${name}(${number}${optionalCharacter})</code>`;
if (BSD_ONLY_SYSCALLS.has(name)) {
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi` +
`?query=${name}&sektion=${number}">${displayAs}</a>`;
}
return `${beginning}<a href="http://man7.org/linux/man-pages/man${number}` +
`/${name}.${number}${optionalCharacter}.html">${displayAs}</a>`;
});
}

@gengjiawen
Copy link
Member

gengjiawen commented Feb 14, 2019

Looks like a bug. Filter curl and uname for now ?

@07Gond
Copy link
Contributor

07Gond commented Feb 27, 2019

https://linux.die.net/man/3/uname this link is for the https://github.com/nodejs/node/blob/master/doc/api/os.md generated by that snippet too.

I think that maybe we have to do something like this following the snippet logic:

const BSD_ONLY_SYSCALLS = new Set(['lchmod']);
const LINUX_DIE_ONLY_SYSCALLS = new Set(['uname']);
const HAXX_ONLY_SYSCALLS = new Set(['curl']);
const MAN_PAGE = /(^|\s)([a-z.]+)\((\d)([a-z]?)\)/gm;

 // Handle references to man pages, eg "open(2)" or "lchmod(2)". 
 // Returns modified text, with such refs replaced with HTML links, for example 
 // '<a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>'. 
 function linkManPages(text) { 
   return text.replace( 
     MAN_PAGE, (match, beginning, name, number, optionalCharacter) => { 
       // Name consists of lowercase letters, 
       // number is a single digit with an optional lowercase letter. 
       const displayAs = `<code>${name}(${number}${optionalCharacter})</code>`; 
  
       if (BSD_ONLY_SYSCALLS.has(name)) { 
        return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi` + 
           `?query=${name}&sektion=${number}">${displayAs}</a>`; 
       } else if (LINUX_DIE_ONLY_SYSCALLS.has(name)) {
		return `${beginning}<a href="https://linux.die.net/man/` + 
           `${number}/${name}">${displayAs}</a>`; 
	   } else if (HAXX_ONLY_SYSCALLS.has(name)) {
		return `${beginning}<a href="https://${name}.haxx.se/docs/manpage.html">${displayAs}</a>`; 
	   } else {
       	return `${beginning}<a href="http://man7.org/linux/man-pages/man${number}` + 
         `/${name}.${number}${optionalCharacter}.html">${displayAs}</a>`;
	   }
     }); 
 }

If we try this we got:
image

If everything is ok here, Can I send a PR for this?

07Gond added a commit to 07Gond/node that referenced this issue Apr 10, 2019
Change the linkManPages function to catch the uname and curl
correct websites on the docs page.

Fixes: nodejs#26074
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.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants