Skip to content

tools: build all.json by combining generated JSON - #21637

Closed
rubys wants to merge 1 commit into
nodejs:masterfrom
rubys:alljson
Closed

tools: build all.json by combining generated JSON#21637
rubys wants to merge 1 commit into
nodejs:masterfrom
rubys:alljson

Conversation

@rubys

@rubysrubys commented Jul 3, 2018

Copy link
Copy Markdown
Member

Notes:

  1. Removed a number of root properties that did not seem relevant: source,
    desc, and introduced_in. There no longer is a source, and the other two are
    from the first include and do not reflect the entire API.

  2. As with doc: all.html is seriously broken link-wise #20100, the current "desc"
    properties sometimes contained in-page links, other times referenced another
    page, and often did not match the links in the original HTML or JSON file.
    I chose to standardize on external links as "desc" values are isolated
    snippets as opposed to all.html which can be viewed as a standalone and self
    contained document.

  3. Eliminated preprocessing for @include entirely, including the test case
    for this function.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are updated
  • commit message follows commit guidelines

@nodejs-github-botnodejs-github-bot added build Issues and PRs related to build files or the CI. doc Issues and PRs related to the documentations. tools Issues and PRs related to the tools directory. labels Jul 3, 2018
@rubys

rubys commented Jul 3, 2018

Copy link
Copy Markdown
MemberAuthor

See #21568 (comment) for the original request.

@Trott

Trott commented Jul 3, 2018

Copy link
Copy Markdown
Member

Not sure if @tolmasky or any of their RunKit colleagues will be able to test this ahead of time, but pinging anyway as their the one significant consumer of our docs-in-JSON-format that I'm aware of. (I don't know if this would help or not, but maybe it would help them if the resulting JSON could be stashed somewhere, maybe in a gist or something.)

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

What will happen with https://github.com/nodejs/node/blob/master/doc/api/index.md? It also contains one include directive.

@rubys

rubys commented Jul 3, 2018

Copy link
Copy Markdown
MemberAuthor

@Trott@tolmaskygist containing both what all.json will look like after this change, and a diff between what it looks like after vs what it looked like before.

@vsemozhetbyt good catch! Initial thoughts: _toc.md should be renamed to _index.md (overwriting this file). allhtml.js and alljson.js would need to be updated to read this data from its new location.

If you agree, I'll make this change and squash the commit.

@vsemozhetbyt

vsemozhetbyt commented Jul 3, 2018

Copy link
Copy Markdown
Contributor

Seems good, but we should also check mentions like this one:

constgtocPath=path.join(docPath,'api','_toc.md');

@rubys
rubysforce-pushed the alljson branch 2 times, most recently from 95ad110 to 511f403CompareJuly 3, 2018 19:04
@vsemozhetbyt

Copy link
Copy Markdown
Contributor

I hope I will be able to review at the weekend. If anybody feels confident to review and land sooner please do)

@Me1000

Copy link
Copy Markdown

Hey all! I work on the RunKit team, thanks for the ping @Trott.

The new output looks like it contains all the existing data. If that is indeed the case (the output is quite large, so maybe I missed something) then it should be fairly easy for us consume the new format. :)

@vsemozhetbyt

vsemozhetbyt commented Jul 7, 2018

Copy link
Copy Markdown
Contributor

One breaking change in the index.html: previously, preprocess.js not only processed @include directives but also stripped the special comments (see commentExpr mentions in preprocess.js). Maybe we should make these comments formatted as HTML comments — these are just two lines in the index.md. Otherwise, they are rendered in the index.html:

cmm

Comment threadtest/doctool/test-make-doc.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the parentheses are redundant now.

Comment threadtools/doc/alljson.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global -> globals?

Comment threadtools/doc/alljson.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. initialize -> Initialize.
  2. Extra space between the sentences.

Comment threadtools/doc/alljson.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.replace('.html', '.json') seems erroneous here?

Comment threadtools/doc/alljson.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this should be /<a href=\\"#/g, `<a href=\\"${href}#`, as double quotes are escaped in .json sources.

Comment threadtools/doc/alljson.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seen[href] -> seen[json]?

Comment threadtools/doc/html.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, it seems this line also need to be updated so that the new HTML comment from index.md could be excluded from all the docs except the index.html.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the .replace(/^@\/\/.*$/gm, '') part.

Comment threadtools/doc/html.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Just to prevent doubts: dotAll flag is supported since V8 6.2, so this line is backportable for Node.js 8 LTS.)

Comment threadtools/doc/alljson.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one more significant nit I've found while diffing the old and new results: new all.json lacks the \n at the end of the file, just after the last }. So maybe it is worth to replace JSON.stringify(results, null, 2) with `${JSON.stringify(results, null, 2)}\n` to be on the safe side)

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

A note: amended commits are not reported to the people that are subscribed to a PR, so maybe it is worth to let everybody know about a new commit version by a comment)

Notes:
1) Removed a number of root properties that did not seem relevant: source,
desc, and introduced_in. There no longer is a source, and the other two are
from the first include and do not reflect the entire API.
2) As with nodejs#20100, the current "desc"
properties sometimes contained in-page links, other times referenced another
page, and often did not match the links in the original HTML or JSON file.
I chose to standardize on external links as "desc" values are isolated
snippets as opposed to all.html which can be viewed as a standalone and self
contained document.
3) Eliminated preprocessing for @include entirely, including the test case
for this function.
4) _toc.md was renamed to index.md.
5) index comments no longer appear in embedded TOCs (left hand side column in
the generated documentation.
@rubys

rubys commented Jul 7, 2018

Copy link
Copy Markdown
MemberAuthor

Perhaps I should just stop squashing commits.

@vsemozhetbyt

Copy link
Copy Markdown
Contributor

@vsemozhetbytvsemozhetbyt added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 7, 2018
@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Let's land this on Monday, maybe somebody from @nodejs/documentation will want to chime in.

vsemozhetbyt pushed a commit that referenced this pull request Jul 9, 2018
Notes:
1) Removed a number of root properties that did not seem relevant:
source, desc, and introduced_in. There no longer is a source, and
the other two are from the first include and do not reflect the
entire API.
2) As with #20100, the current
"desc" properties sometimes contained in-page links, other times
referenced another page, and often did not match the links in the
original HTML or JSON file. I chose to standardize on external links
as "desc" values are isolated snippets as opposed to all.html which
can be viewed as a standalone and self contained document.
3) Eliminated preprocessing for @include entirely, including the test
case for this function.
4) _toc.md was renamed to index.md.
5) index comments no longer appear in embedded TOCs (left hand side
column in the generated documentation.
PR-URL: #21637
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@vsemozhetbyt

Copy link
Copy Markdown
Contributor

Landed in 0c743b5
Thank you!

targos pushed a commit that referenced this pull request Jul 12, 2018
Notes:
1) Removed a number of root properties that did not seem relevant:
source, desc, and introduced_in. There no longer is a source, and
the other two are from the first include and do not reflect the
entire API.
2) As with #20100, the current
"desc" properties sometimes contained in-page links, other times
referenced another page, and often did not match the links in the
original HTML or JSON file. I chose to standardize on external links
as "desc" values are isolated snippets as opposed to all.html which
can be viewed as a standalone and self contained document.
3) Eliminated preprocessing for @include entirely, including the test
case for this function.
4) _toc.md was renamed to index.md.
5) index comments no longer appear in embedded TOCs (left hand side
column in the generated documentation.
PR-URL: #21637
Reviewed-By: Vse Mozhet Byt <vsemozhetbyt@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
@targostargos removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Jul 12, 2018
@targostargos mentioned this pull request Jul 17, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

buildIssues and PRs related to build files or the CI.docIssues and PRs related to the documentations.toolsIssues and PRs related to the tools directory.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants

@rubys@Trott@vsemozhetbyt@Me1000@targos@nodejs-github-bot