-
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 HTML generation #20307
tools: simplify HTML generation #20307
Conversation
This comment has been minimized.
This comment has been minimized.
Aren't these files linted? |
@richardlau I've meant the old rudiments that are accepted by the linter but are usually fixed now: |
@addaleax Sorry, to be sure: your approval has been made in 2 minutes after the PR had been filed: is it intended? |
@vsemozhetbyt Yes, that was an actual review. :) If you want something more explicit: This looks correct to me, and if CI passes then I’m happy. And it’s awesome that you’re cleaning this mess up, so that’s very much appreciated too. :) |
I am not sure if we can consider a fast-tracking here: this is a code change and it touches build script. But it is contained in doc domain only and does not change anything in the output and results. So if anybody does approve fast-tracking, please, add 👍 here and I will start to clean the script on after this landed. |
I've reverted an inadvertent comment change. |
Landed in ad6a65b |
PR-URL: #20307 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
PR-URL: #20307 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
PR-URL: #20307 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesIn
tools/doc/html.js
we have 3 operations that have little benefit but complicate the file significantly.doc/template.html
.doc/api/_toc.md
.tools/doc/preprocess.js
and calling its main function.While doing 1 and 2 asynchronously can have a performance benefit, it is rather small (both files are ~1.5 KB). Besides, the downsides are significant:
tools/doc/html.js
is required intools/doc/generate.js
andtest/doctool/test-doctool-html.js
. While the first script calls the main function once per requiring, the second script calls it many times and all these times the samedoc/template.html
is loaded needlessly.Asynchronous loading of
doc/ap/_toc.md
makes the script overcomplicated to the extent of this comment:node/tools/doc/html.js
Line 45 in 2a30bfe
tools/doc/preprocess.js
is processing@include
instructions. Also, as one goes, it strips special comments. There are no@include
instructions indoc/ap/_toc.md
so the requiring this module is excessiveness.This PR try to eliminate all downsides in this way:
As we have only one HTML template, we can exclude it as an option from cli chain, incorporate its path in
tools/doc/html.js
and preload it synchronously once per module initialization.We can preload
doc/api/_toc.md
synchronously and delete a huge async machinery.We can replace
tools/doc/preprocess.js
requiring with one-liner comment stripping in place.This PR reduces the code almost by 50 lines producing the same result.
Please, ignore any remaining stylistic issues while reviewing the changes: I am going to modernize and optimize the whole script after this PR. This change is singled out to not mingle logic refactoring with many small changes scattering over the file.