-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools: add unified plugin changing links for html docs
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 <[email protected]>
- Loading branch information
1 parent
7bc8c85
commit da1e5ae
Showing
6 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Usage and Example | ||
|
||
## Usage | ||
|
||
`node \[options\] index.js` | ||
|
||
Please see the [Command Line Options][] document for more information. | ||
|
||
## Example | ||
|
||
An example of a [web server][] written with Node.js which responds with | ||
`'Hello, World!'`: | ||
|
||
## See also | ||
|
||
Check out also [this guide][] | ||
|
||
[Command Line Options]: cli.md#options | ||
[this guide]: https://nodejs.org/ | ||
[web server]: example.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"doc/api/synopsis.md": { | ||
"command line options": "cli.html#cli_command_line_options", | ||
"web server": "http.html" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const visit = require('unist-util-visit'); | ||
|
||
module.exports = { | ||
replaceLinks | ||
}; | ||
|
||
function replaceLinks({ filename, linksMapper }) { | ||
return (tree) => { | ||
const fileHtmlUrls = linksMapper[filename]; | ||
|
||
visit(tree, 'definition', (node) => { | ||
const htmlUrl = fileHtmlUrls && fileHtmlUrls[node.identifier]; | ||
|
||
if (htmlUrl && typeof htmlUrl === 'string') { | ||
node.url = htmlUrl; | ||
} | ||
}); | ||
}; | ||
} |