-
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: produce JSON documentation using unified/remark/rehype #21697
Conversation
This pull request will require a lot of discussion. Other puzzles:
My current code is rejecting the constructor for console as the first signature defines parameters that are included in the list list below (at least not as first level items):
I can fix this up, but not seeing the Console constructor in the current output means that I'm flying blind. |
tools/doc/json2.js
Outdated
@@ -0,0 +1,491 @@ | |||
// Copyright Joyent, Inc. and other Node contributors. |
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.
Is this a brand new file or is it pulled from another source? brand new files do not require the copyright header to be added.
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.
Ultimately, it will be renamed to tools/doc/json2.js
, and contains significant content from the original source.
Currently separate so that side by side comparisons of the output can be produced, via jsondiff.js, which will be removed when this effort is complete.
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.
Ok, thanks for clarification :-)
Latest issue: files like buffer.json sometimes parses stability correctly, e.g.:
And other times misses it entirely:
The issue here is the embedded newline. The bug here is that |
This pull request is no longer Work remaining to be done before this lands: rename json2.js to json.js (overwriting the original source) and deleting jsondiff.js. For the moment, I'm leaving both sources and the diff tool with the thought that it would help reviewers. Once #21490 lands, further refactoring and cleanup is possible. |
Removed the |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
CI is all green. |
I've compared the diff in <!--introduced_in=v...-->
<!-- type=misc -->
<!--type=class-->
<!--type=module-->
<!-- type=global -->
<!-- type=var -->
<!--type=event-->
<!--type=example-->
<!-- name=dgram -->
<!--name=esm-->
<!--name=fs-->
<!--name=module-->
<!--name=SIGINT, SIGHUP, etc.-->
<!--name=querystring-->
<!--name=vm--> Not sure if this is breaking in any aspect. Maybe we can ignore this change as these comments seem needed at the generation stage only. |
Ignorable note: nodes.forEach((node, i) => { -> nodes.forEach(({ type, value, children }, i) => { or: return nodes.map((node) => { -> return nodes.map(({ type, position, value, children }) => { etc. |
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.
Just some comment nits.
tools/doc/json.js
Outdated
const metaExpr = /<!--([^=]+)=([^-]+)-->\n*/g; | ||
const stabilityExpr = /^Stability: ([0-5])(?:\s*-\s*)?(.*)$/s; | ||
|
||
// extract definitions |
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: // Extract definitions.
tools/doc/json.js
Outdated
// Extract (and remove) metadata that is not directly inferable | ||
// from the markdown itself. | ||
nodes.forEach((node, i) => { | ||
// Input: <!-- name=module -->; output: {name: module} |
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: output: { name: module }.
tools/doc/json.js
Outdated
values.push(item); | ||
current = item; | ||
// Pluralize type to determine which 'bucket' to put this section | ||
// in. |
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: it seems this can be unwrapped.
tools/doc/json.js
Outdated
|
||
delete section.list; | ||
// Add this section to the parent. Sometimes we have two headings with a |
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: extra space in parent. Sometimes
.
tools/doc/json.js
Outdated
|
||
delete section.list; | ||
// Add this section to the parent. Sometimes we have two headings with a | ||
// single blob of description. If the preceding entry at this level |
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.
Ditto in description. If
.
tools/doc/json.js
Outdated
` > ${text}` | ||
); | ||
|
||
// At this point, the name should match. If it doesn't find one that does. |
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.
Ditto in match. If
.
tools/doc/json.js
Outdated
} | ||
return; | ||
} | ||
// Stablility marker: > Stability: ... |
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.
Stablility -> Stability
tools/doc/json.js
Outdated
return src; | ||
} | ||
|
||
|
||
// This section parse out the contents of an H# tag. | ||
|
||
// To reduse escape slashes in RegExp string components. |
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.
Sorry, old debt: reduse -> reduce.
tools/doc/json.js
Outdated
return src; | ||
} | ||
|
||
|
||
// This section parse out the contents of an H# tag. |
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.
Sorry, old debt: parse out -> parses out.
CC @nodejs/documentation @nodejs/build @nodejs/build-files: please, let us know if you plan to review this PR in the near future. Otherwise, I will land it, say, on Wednesday. |
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.
Rubber-stamp LGTM
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.
RSLGTM
... but we can update to the latest :-)
rebased |
PR-URL: #21697 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
Landed in f41dd55 |
Depends on #21616 to land on |
PR-URL: #21697 Reviewed-By: Vse Mozhet Byt <[email protected]> Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
PR-URL: nodejs#22749 Refs: nodejs#21697 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
PR-URL: #22749 Refs: #21697 Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
work in progress. tools/doc/json2.js is a first pass attempt to convert tools/doc/json.js to a new markdown toolchain. The original intent was to produce functionally identical JSON, but some oddities have been found along the way. Examples: (highest priority first):
The current (soon to be previous?) processing is based on a stream of tokens and a state machine. The new process is based on a pipeline of processors that have access to a tree of tokens. Care has been taken to not modify the stream so that this processor can be added to the pipeline that produces HTML.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes