-
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
tools: fix comment nits in tools/doc/*.js files #19696
Closed
Closed
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -33,7 +33,7 @@ module.exports = toHTML; | |
const STABILITY_TEXT_REG_EXP = /(.*:)\s*(\d)([\s\S]*)/; | ||
const DOC_CREATED_REG_EXP = /<!--\s*introduced_in\s*=\s*v([0-9]+)\.([0-9]+)\.([0-9]+)\s*-->/; | ||
|
||
// customized heading without id attribute | ||
// Customized heading without id attribute. | ||
const renderer = new marked.Renderer(); | ||
renderer.heading = function(text, level) { | ||
return `<h${level}>${text}</h${level}>\n`; | ||
|
@@ -42,7 +42,7 @@ marked.setOptions({ | |
renderer: renderer | ||
}); | ||
|
||
// TODO(chrisdickinson): never stop vomitting / fix this. | ||
// TODO(chrisdickinson): never stop vomiting / fix this. | ||
const gtocPath = path.resolve(path.join( | ||
__dirname, | ||
'..', | ||
|
@@ -128,16 +128,16 @@ function render(opts, cb) { | |
var { lexed, filename, template } = opts; | ||
const nodeVersion = opts.nodeVersion || process.version; | ||
|
||
// get the section | ||
// Get the section. | ||
const section = getSection(lexed); | ||
|
||
filename = path.basename(filename, '.md'); | ||
|
||
parseText(lexed); | ||
lexed = parseLists(lexed); | ||
|
||
// generate the table of contents. | ||
// this mutates the lexed contents in-place. | ||
// Generate the table of contents. | ||
// This mutates the lexed contents in-place. | ||
buildToc(lexed, filename, function(er, toc) { | ||
if (er) return cb(er); | ||
|
||
|
@@ -162,8 +162,8 @@ function render(opts, cb) { | |
|
||
template = template.replace(/__ALTDOCS__/, altDocs(filename)); | ||
|
||
// content has to be the last thing we do with | ||
// the lexed tokens, because it's destructive. | ||
// Content has to be the last thing we do with the lexed tokens, | ||
// because it's destructive. | ||
const content = marked.parser(lexed); | ||
template = template.replace(/__CONTENT__/g, content); | ||
|
||
|
@@ -188,7 +188,7 @@ function analyticsScript(analytics) { | |
`; | ||
} | ||
|
||
// replace placeholders in text tokens | ||
// Replace placeholders in text tokens. | ||
function replaceInText(text) { | ||
return linkJsTypeDocs(linkManPages(text)); | ||
} | ||
|
@@ -244,8 +244,8 @@ function altDocs(filename) { | |
`; | ||
} | ||
|
||
// handle general body-text replacements | ||
// for example, link man page references to the actual page | ||
// Handle general body-text replacements. | ||
// For example, link man page references to the actual page. | ||
function parseText(lexed) { | ||
lexed.forEach(function(tok) { | ||
if (tok.type === 'table') { | ||
|
@@ -272,8 +272,8 @@ function parseText(lexed) { | |
}); | ||
} | ||
|
||
// just update the list item text in-place. | ||
// lists that come right after a heading are what we're after. | ||
// Just update the list item text in-place. | ||
// Lists that come right after a heading are what we're after. | ||
function parseLists(input) { | ||
var state = null; | ||
const savedState = []; | ||
|
@@ -299,8 +299,8 @@ function parseLists(input) { | |
const stabilityMatch = tok.text.match(STABILITY_TEXT_REG_EXP); | ||
const stability = Number(stabilityMatch[2]); | ||
const isStabilityIndex = | ||
index - 2 === headingIndex || // general | ||
index - 3 === headingIndex; // with api_metadata block | ||
index - 2 === headingIndex || // General. | ||
index - 3 === headingIndex; // With api_metadata block. | ||
|
||
if (heading && isStabilityIndex) { | ||
heading.stability = stability; | ||
|
@@ -408,17 +408,17 @@ function parseYAML(text) { | |
return html.join('\n'); | ||
} | ||
|
||
// Syscalls which appear in the docs, but which only exist in BSD / OSX | ||
// Syscalls which appear in the docs, but which only exist in BSD / OSX. | ||
const BSD_ONLY_SYSCALLS = new Set(['lchmod']); | ||
|
||
// Handle references to man pages, eg "open(2)" or "lchmod(2)" | ||
// Returns modified text, with such refs replace with HTML links, for example | ||
// '<a href="http://man7.org/linux/man-pages/man2/open.2.html">open(2)</a>' | ||
// 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( | ||
/(^|\s)([a-z.]+)\((\d)([a-z]?)\)/gm, | ||
(match, beginning, name, number, optionalCharacter) => { | ||
// name consists of lowercase letters, number is a single digit | ||
// Name consists of lowercase letters, number is a single digit. | ||
const displayAs = `${name}(${number}${optionalCharacter})`; | ||
if (BSD_ONLY_SYSCALLS.has(name)) { | ||
return `${beginning}<a href="https://www.freebsd.org/cgi/man.cgi?query=${name}` + | ||
|
@@ -436,7 +436,7 @@ function linkJsTypeDocs(text) { | |
var typeMatches; | ||
|
||
// Handle types, for example the source Markdown might say | ||
// "This argument should be a {Number} or {String}" | ||
// "This argument should be a {Number} or {String}". | ||
for (i = 0; i < parts.length; i += 2) { | ||
typeMatches = parts[i].match(/\{([^}]+)\}/g); | ||
if (typeMatches) { | ||
|
@@ -446,7 +446,7 @@ function linkJsTypeDocs(text) { | |
} | ||
} | ||
|
||
//XXX maybe put more stuff here? | ||
// XXX Maybe put more stuff here? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: being on it, you might also change There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
return parts.join('`'); | ||
} | ||
|
||
|
@@ -461,7 +461,7 @@ function parseAPIHeader(text) { | |
return text; | ||
} | ||
|
||
// section is just the first heading | ||
// Section is just the first heading. | ||
function getSection(lexed) { | ||
for (var i = 0, l = lexed.length; i < l; i++) { | ||
var tok = lexed[i]; | ||
|
@@ -533,7 +533,7 @@ const numberRe = /^(\d*)/; | |
function versionSort(a, b) { | ||
a = a.trim(); | ||
b = b.trim(); | ||
let i = 0; // common prefix length | ||
let i = 0; // Common prefix length. | ||
while (i < a.length && i < b.length && a[i] === b[i]) i++; | ||
a = a.substr(i); | ||
b = b.substr(i); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
macOS
since we're changing this line?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.
Done.