-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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: simplify tools/doc/preprocess.js #19539
tools: simplify tools/doc/preprocess.js #19539
Conversation
CI-lite: https://ci.nodejs.org/job/node-test-pull-request-lite/289/ Let me know if we need full CI for this. |
tools/doc/preprocess.js
Outdated
|
||
function processIncludes(inputFile, input, cb) { | ||
const includes = input.match(includeExpr); | ||
if (includes === null) return cb(null, input); | ||
if (includes === null) return cb(null, input.replace(commentExpr, '')); |
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.
Nit: I think dominant style is to put if
body in a new line.
Added a fixup commit: put long |
Not sure if this can be fast-tracked. Feel free to add the label if so. |
PR-URL: #19539 Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
Landed in cde98ce |
PR-URL: #19539 Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
PR-URL: #19539 Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Daijiro Wachi <[email protected]>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesThis PR seems to be a big refactoring, but it is rather simple and trims the script down almost by half, streamlining the logic significantly.
Investigated status quo in
preprocess.js
tools/doc/preprocess.js
seems to either contain artifacts from some very old doc system state or to be designed for a much more complicated doc system than the current one, just in case.preprocess.js
has two aims: strip@//
comments in doc sources + replace@include
directives with outer file content.preprocess.js
is designed to support repeated@include
directives so it uses caching.preprocess.js
is designed to support nested@include
directives so it calls its main exported function recursively.preprocess.js
is designed to support docs with various file extensions (.md
,.markdown
, etc).Investigated status quo in doc building system and doc sources
doc/api/_toc.md
has@//
comments .doc/api/index.md
anddoc/api/all.md
have@include
directives. None of these cases has repeated or nested directives, so neither caching nor recursive processing is needed here..md
extension.tools/doc/generate.js
,preprocess.js
is also used intools/doc/html.js
andtest/doctool/test-doctool-html.js
. Neither of these cases means repeated or nested directives as well.Simplification strategy
.md
file extension.I've built the docs on Windows (using #19330) before and after these changes and both doc sets are identical +
doctool
tests are OK.