From c0429d197f4e94e48c324d91a2392520efc54899 Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Wed, 22 Feb 2017 20:12:46 +0530 Subject: [PATCH 1/5] docs: Change broken fg(1) links to fg(1p) The fg(1) links in the readline docs have moved from `http://man7.org/linux/man-pages/man1/fg.1.html` to `http://man7.org/linux/man-pages/man1/fg.1p.html`. It also modifies the regex for replacing man page links in docs by allowing optional character after number. eg: fg(1) and fg(1p) will both be now parsed and replaced. Fixes: https://github.com/nodejs/node/issues/11492 --- doc/api/readline.md | 4 ++-- tools/doc/html.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/doc/api/readline.md b/doc/api/readline.md index 32fad5732c70df..23669a8f65c88a 100644 --- a/doc/api/readline.md +++ b/doc/api/readline.md @@ -124,7 +124,7 @@ added: v0.7.5 The `'SIGCONT'` event is emitted when a Node.js process previously moved into the background using `-Z` (i.e. `SIGTSTP`) is then brought back to the -foreground using fg(1). +foreground using fg(1p). If the `input` stream was paused *before* the `SIGTSTP` request, this event will not be emitted. @@ -174,7 +174,7 @@ input, typically known as `SIGTSTP`. If there are no `SIGTSTP` event listeners registered when the `input` stream receives a `SIGTSTP`, the Node.js process will be sent to the background. -When the program is resumed using fg(1), the `'pause'` and `SIGCONT` events +When the program is resumed using fg(1p), the `'pause'` and `SIGCONT` events will be emitted. These can be used to resume the `input` stream. The `'pause'` and `'SIGCONT'` events will not be emitted if the `input` was diff --git a/tools/doc/html.js b/tools/doc/html.js index 3dd6f83da503df..a4d6c026d10a19 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -288,15 +288,15 @@ var BSD_ONLY_SYSCALLS = new Set(['lchmod']); // Returns modified text, with such refs replace with HTML links, for example // 'open(2)' function linkManPages(text) { - return text.replace(/ ([a-z.]+)\((\d)\)/gm, function(match, name, number) { + return text.replace(/ ([a-z.]+)\((\d)([a-z]?)\)/gm, function(match, name, number, optionalCharacter) { // name consists of lowercase letters, number is a single digit - var displayAs = name + '(' + number + ')'; + var displayAs = name + '(' + number + optionalCharacter + ')'; if (BSD_ONLY_SYSCALLS.has(name)) { return ' ' + displayAs + ''; } else { return ' ' + displayAs + ''; + '/' + name + '.' + (number + optionalCharacter) + '.html">' + displayAs + ''; } }); } From 1f7990702f7dc68d082b140fddfdc2ff675f653a Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Wed, 22 Feb 2017 22:46:03 +0530 Subject: [PATCH 2/5] Make linter happy --- tools/doc/html.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index a4d6c026d10a19..94ebd127970bff 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -288,17 +288,20 @@ var BSD_ONLY_SYSCALLS = new Set(['lchmod']); // Returns modified text, with such refs replace with HTML links, for example // 'open(2)' function linkManPages(text) { - return text.replace(/ ([a-z.]+)\((\d)([a-z]?)\)/gm, function(match, name, number, optionalCharacter) { - // name consists of lowercase letters, number is a single digit - var displayAs = name + '(' + number + optionalCharacter + ')'; - if (BSD_ONLY_SYSCALLS.has(name)) { - return ' ' + displayAs + ''; - } else { - return ' ' + displayAs + ''; - } - }); + return text.replace( + / ([a-z.]+)\((\d)([a-z]?)\)/gm, + function(match, name, number, optionalCharacter) { + // name consists of lowercase letters, number is a single digit + var displayAs = name + '(' + number + optionalCharacter + ')'; + if (BSD_ONLY_SYSCALLS.has(name)) { + return ' ' + displayAs + ''; + } else { + return ' ' + + displayAs + ''; + } + }); } function linkJsTypeDocs(text) { From 4b576a39cd4f619d2915d0f768de3e4ed284fdb1 Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Wed, 22 Feb 2017 22:56:35 +0530 Subject: [PATCH 3/5] Add tests for man page link replacement --- test/doctool/test-doctool-html.js | 6 ++++-- test/fixtures/doc_with_yaml.md | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/test/doctool/test-doctool-html.js b/test/doctool/test-doctool-html.js index 442381b54d7b72..ba1f751b022a26 100644 --- a/test/doctool/test-doctool-html.js +++ b/test/doctool/test-doctool-html.js @@ -48,13 +48,15 @@ const testData = [ '

Foobar II#

' + ' ' + - '

Describe Foobar II in more detail here.

' + + '

Describe Foobar II in more detail here.' + + 'fg(1)

' + '

Deprecated thingy#' + '

' + '

Describe ' + - 'Deprecated thingy in more detail here.

' + + 'Deprecated thingy in more detail here.' + + 'fg(1p)

' + '

Something#

' + ' ' + diff --git a/test/fixtures/doc_with_yaml.md b/test/fixtures/doc_with_yaml.md index 493c2e7e4268b2..4f4aa63f458cc4 100644 --- a/test/fixtures/doc_with_yaml.md +++ b/test/fixtures/doc_with_yaml.md @@ -14,7 +14,7 @@ added: - v4.2.0 --> -Describe `Foobar II` in more detail here. +Describe `Foobar II` in more detail here. fg(1) ## Deprecated thingy -Describe `Deprecated thingy` in more detail here. +Describe `Deprecated thingy` in more detail here. fg(1p) ## Something From 169f4d874d5b1df8b51eda16551dfaf7f4b5a06a Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Wed, 22 Feb 2017 23:22:16 +0530 Subject: [PATCH 4/5] Use fat arrow and template strings --- tools/doc/html.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/doc/html.js b/tools/doc/html.js index 94ebd127970bff..1dbdc425616d27 100644 --- a/tools/doc/html.js +++ b/tools/doc/html.js @@ -290,16 +290,15 @@ var BSD_ONLY_SYSCALLS = new Set(['lchmod']); function linkManPages(text) { return text.replace( / ([a-z.]+)\((\d)([a-z]?)\)/gm, - function(match, name, number, optionalCharacter) { + (match, name, number, optionalCharacter) => { // name consists of lowercase letters, number is a single digit - var displayAs = name + '(' + number + optionalCharacter + ')'; + var displayAs = `${name}(${number}${optionalCharacter})`; if (BSD_ONLY_SYSCALLS.has(name)) { - return ' ' + displayAs + ''; + return ` ${displayAs}`; } else { - return ' ' + - displayAs + ''; + return ` ${displayAs}`; } }); } From d48c6278137ad7d4166b91bd3cadc941c767b002 Mon Sep 17 00:00:00 2001 From: Karan Thakkar Date: Thu, 23 Feb 2017 11:42:16 +0530 Subject: [PATCH 5/5] Fix doctool json test --- test/doctool/test-doctool-json.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/doctool/test-doctool-json.js b/test/doctool/test-doctool-json.js index ae7b2007b7d2ef..c38cfc149ac788 100644 --- a/test/doctool/test-doctool-json.js +++ b/test/doctool/test-doctool-json.js @@ -103,7 +103,7 @@ const testData = [ added: ['v5.3.0', 'v4.2.0'] }, desc: '

Describe Foobar II in more detail ' + - 'here.

\n', + 'here. fg(1)

\n', type: 'module', displayName: 'Foobar II' }, @@ -115,7 +115,7 @@ const testData = [ deprecated: ['v2.0.0'] }, desc: '

Describe Deprecated thingy in more ' + - 'detail here.

\n', + 'detail here. fg(1p)

\n', type: 'module', displayName: 'Deprecated thingy' },