GeezerVison is showing github.com — tools: build all.json by combining generated JSON · nodejs/node@b9bbbbe
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: Makefile +5-3Lines changed: 5 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -622,7 +622,7 @@ doc-only: $(apidoc_dirs) $(apiassets) ## Builds the docs with the local or the | 622 | 622 | if [ ! -d doc/api/assets ]; then \ | 623 | 623 | $(MAKE) tools/doc/node_modules/js-yaml/package.json; \ | 624 | 624 | fi; | 625 | | - @$(MAKE) $(apidocs_html) $(apidocs_json) | | 625 | + @$(MAKE) out/doc/api/all.html out/doc/api/all.json | 626 | 626 |
| 627 | 627 | .PHONY: doc | 628 | 628 | doc: $(NODE_EXE) doc-only | @@ -672,10 +672,12 @@ out/doc/api/%.json: doc/api/%.md tools/doc/generate.js tools/doc/json.js | 672 | 672 | out/doc/api/%.html: doc/api/%.md tools/doc/generate.js tools/doc/html.js | 673 | 673 | $(call available-node, $(gen-html)) | 674 | 674 |
| 675 | | -out/doc/api/all.html: $(filter-out out/doc/api/all.html, $(apidocs_html)) \ | 676 | | - tools/doc/allhtml.js | | 675 | +out/doc/api/all.html: $(apidocs_html) tools/doc/allhtml.js | 677 | 676 | $(call available-node, tools/doc/allhtml.js) | 678 | 677 |
| | 678 | +out/doc/api/all.json: $(apidocs_json) tools/doc/alljson.js | | 679 | + $(call available-node, tools/doc/alljson.js) | | 680 | + | 679 | 681 | .PHONY: docopen | 680 | 682 | docopen: $(apidocs_html) | 681 | 683 | @$(PYTHON) -mwebbrowser file://$(PWD)/out/doc/api/all.html | |
Collapse file Copy file name to clipboardExpand all lines: doc/api/_toc.md -62Lines changed: 0 additions & 62 deletions Collapse file Copy file name to clipboardExpand all lines: doc/api/all.md -50Lines changed: 0 additions & 50 deletions Collapse file Copy file name to clipboard +64-1Lines changed: 64 additions & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| 1 | | -@include _toc.md | | 1 | +<!-- | | 2 | + NB(chrisdickinson): if you move this file, be sure to update | | 3 | + tools/doc/html.js to point at the new location. | | 4 | +--> | | 5 | + | | 6 | +<!--introduced_in=v0.10.0--> | | 7 | + | | 8 | +* [About these Docs](documentation.html) | | 9 | +* [Usage & Example](synopsis.html) | | 10 | + | | 11 | +<div class="line"></div> | | 12 | + | | 13 | +* [Assertion Testing](assert.html) | | 14 | +* [Async Hooks](async_hooks.html) | | 15 | +* [Buffer](buffer.html) | | 16 | +* [C++ Addons](addons.html) | | 17 | +* [C/C++ Addons - N-API](n-api.html) | | 18 | +* [Child Processes](child_process.html) | | 19 | +* [Cluster](cluster.html) | | 20 | +* [Command Line Options](cli.html) | | 21 | +* [Console](console.html) | | 22 | +* [Crypto](crypto.html) | | 23 | +* [Debugger](debugger.html) | | 24 | +* [Deprecated APIs](deprecations.html) | | 25 | +* [DNS](dns.html) | | 26 | +* [Domain](domain.html) | | 27 | +* [ECMAScript Modules](esm.html) | | 28 | +* [Errors](errors.html) | | 29 | +* [Events](events.html) | | 30 | +* [File System](fs.html) | | 31 | +* [Globals](globals.html) | | 32 | +* [HTTP](http.html) | | 33 | +* [HTTP/2](http2.html) | | 34 | +* [HTTPS](https.html) | | 35 | +* [Inspector](inspector.html) | | 36 | +* [Internationalization](intl.html) | | 37 | +* [Modules](modules.html) | | 38 | +* [Net](net.html) | | 39 | +* [OS](os.html) | | 40 | +* [Path](path.html) | | 41 | +* [Performance Hooks](perf_hooks.html) | | 42 | +* [Process](process.html) | | 43 | +* [Punycode](punycode.html) | | 44 | +* [Query Strings](querystring.html) | | 45 | +* [Readline](readline.html) | | 46 | +* [REPL](repl.html) | | 47 | +* [Stream](stream.html) | | 48 | +* [String Decoder](string_decoder.html) | | 49 | +* [Timers](timers.html) | | 50 | +* [TLS/SSL](tls.html) | | 51 | +* [Trace Events](tracing.html) | | 52 | +* [TTY](tty.html) | | 53 | +* [UDP/Datagram](dgram.html) | | 54 | +* [URL](url.html) | | 55 | +* [Utilities](util.html) | | 56 | +* [V8](v8.html) | | 57 | +* [VM](vm.html) | | 58 | +* [Worker Threads](worker_threads.html) | | 59 | +* [ZLIB](zlib.html) | | 60 | + | | 61 | +<div class="line"></div> | | 62 | + | | 63 | +* [GitHub Repo & Issue Tracker](https://github.com/nodejs/node) | | 64 | +* [Mailing List](https://groups.google.com/group/nodejs) |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-doctool-html.js +26-38Lines changed: 26 additions & 38 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 11 | 11 | const assert = require('assert'); | 12 | 12 | const { readFile } = require('fs'); | 13 | 13 | const fixtures = require('../common/fixtures'); | 14 | | -const processIncludes = require('../../tools/doc/preprocess.js'); | 15 | 14 | const toHTML = require('../../tools/doc/html.js'); | 16 | 15 |
| 17 | 16 | // Test data is a list of objects with two properties. | @@ -64,15 +63,6 @@ const testData = [ | 64 | 63 | '<!-- This is not a metadata comment --> ' + | 65 | 64 | '<p>Describe <code>Something</code> in more detail here. </p>' | 66 | 65 | }, | 67 | | - { | 68 | | - file: fixtures.path('doc_with_includes.md'), | 69 | | - html: '<!-- [start-include:doc_inc_1.md] -->' + | 70 | | - '<p>Look <a href="doc_inc_2.html#doc_inc_2_foobar">here</a>!</p>' + | 71 | | - '<!-- [end-include:doc_inc_1.md] --><!-- [start-include:doc_inc_2.md] -->' + | 72 | | - '<h1>foobar<span><a class="mark" href="#doc_inc_2_foobar" ' + | 73 | | - 'id="doc_inc_2_foobar">#</a></span></h1>' + | 74 | | - '<p>I exist and am being linked to.</p><!-- [end-include:doc_inc_2.md] -->' | 75 | | - }, | 76 | 66 | { | 77 | 67 | file: fixtures.path('sample_document.md'), | 78 | 68 | html: '<ol><li>fish</li><li><p>fish</p></li><li><p>Redfish</p></li>' + | @@ -90,36 +80,34 @@ testData.forEach(({ file, html, analyticsId }) => { | 90 | 80 |
| 91 | 81 | readFile(file, 'utf8', common.mustCall((err, input) => { | 92 | 82 | assert.ifError(err); | 93 | | - processIncludes(file, input, common.mustCall((err, preprocessed) => { | 94 | | - assert.ifError(err); | 95 | 83 |
| 96 | | - toHTML( | 97 | | - { | 98 | | - input: preprocessed, | 99 | | - filename: 'foo', | 100 | | - nodeVersion: process.version, | 101 | | - analytics: analyticsId, | 102 | | - }, | 103 | | - common.mustCall((err, output) => { | 104 | | - assert.ifError(err); | | 84 | + toHTML( | | 85 | + { | | 86 | + input: input, | | 87 | + filename: 'foo', | | 88 | + nodeVersion: process.version, | | 89 | + analytics: analyticsId, | | 90 | + }, | | 91 | + common.mustCall((err, output) => { | | 92 | + assert.ifError(err); | 105 | 93 |
| 106 | | - const actual = output.replace(spaces, ''); | 107 | | - // Assert that the input stripped of all whitespace contains the | 108 | | - // expected markup. | 109 | | - assert(actual.includes(expected)); | | 94 | + const actual = output.replace(spaces, ''); | | 95 | + // Assert that the input stripped of all whitespace contains the | | 96 | + // expected markup. | | 97 | + assert(actual.includes(expected)); | 110 | 98 |
| 111 | | - // Testing the insertion of Google Analytics script when | 112 | | - // an analytics id is provided. Should not be present by default. | 113 | | - const scriptDomain = 'google-analytics.com'; | 114 | | - if (includeAnalytics) { | 115 | | - assert(actual.includes(scriptDomain), | 116 | | - `Google Analytics script was not present in "${actual}"`); | 117 | | - } else { | 118 | | - assert.strictEqual(actual.includes(scriptDomain), false, | 119 | | - 'Google Analytics script was present in ' + | 120 | | - `"${actual}"`); | 121 | | - } | 122 | | - })); | 123 | | - })); | | 99 | + // Testing the insertion of Google Analytics script when | | 100 | + // an analytics id is provided. Should not be present by default. | | 101 | + const scriptDomain = 'google-analytics.com'; | | 102 | + if (includeAnalytics) { | | 103 | + assert(actual.includes(scriptDomain), | | 104 | + `Google Analytics script was not present in "${actual}"`); | | 105 | + } else { | | 106 | + assert.strictEqual(actual.includes(scriptDomain), false, | | 107 | + 'Google Analytics script was present in ' + | | 108 | + `"${actual}"`); | | 109 | + } | | 110 | + }) | | 111 | + ); | 124 | 112 | })); | 125 | 113 | }); |
Collapse file Copy file name to clipboardExpand all lines: test/doctool/test-make-doc.js +4-6Lines changed: 4 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,17 +13,16 @@ const path = require('path'); | 13 | 13 |
| 14 | 14 | const apiPath = path.resolve(__dirname, '..', '..', 'out', 'doc', 'api'); | 15 | 15 | const allDocs = fs.readdirSync(apiPath); | 16 | | -assert.ok(allDocs.includes('_toc.html')); | | 16 | +assert.ok(allDocs.includes('index.html')); | 17 | 17 |
| 18 | 18 | const actualDocs = allDocs.filter( | 19 | 19 | (name) => { | 20 | 20 | const extension = path.extname(name); | 21 | | - return (extension === '.html' || extension === '.json') && | 22 | | - name !== '_toc.html'; | | 21 | + return extension === '.html' || extension === '.json'; | 23 | 22 | } | 24 | 23 | ); | 25 | 24 |
| 26 | | -const toc = fs.readFileSync(path.resolve(apiPath, '_toc.html'), 'utf8'); | | 25 | +const toc = fs.readFileSync(path.resolve(apiPath, 'index.html'), 'utf8'); | 27 | 26 | const re = /href="([^/]+\.html)"/; | 28 | 27 | const globalRe = new RegExp(re, 'g'); | 29 | 28 | const links = toc.match(globalRe); | @@ -32,8 +31,7 @@ assert.notStrictEqual(links, null); | 32 | 31 | // Filter out duplicate links, leave just filenames, add expected JSON files. | 33 | 32 | const linkedHtmls = [...new Set(links)].map((link) => link.match(re)[1]); | 34 | 33 | const expectedJsons = linkedHtmls | 35 | | - .map((name) => name.replace('.html', '.json')) | 36 | | - .concat('_toc.json'); | | 34 | + .map((name) => name.replace('.html', '.json')); | 37 | 35 | const expectedDocs = linkedHtmls.concat(expectedJsons); | 38 | 36 |
| 39 | 37 | // Test that all the relative links in the TOC match to the actual documents. | |
Collapse file Copy file name to clipboardExpand all lines: test/fixtures/doc_with_includes.md -2Lines changed: 0 additions & 2 deletions Collapse file Copy file name to clipboardExpand all lines: tools/doc/allhtml.js +7-6Lines changed: 7 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,7 @@ const htmlFiles = fs.readdirSync(source, 'utf8') | 12 | 12 | .filter((name) => name.includes('.html') && name !== 'all.html'); | 13 | 13 |
| 14 | 14 | // Read the table of contents. | 15 | | -const toc = fs.readFileSync(source + '/_toc.html', 'utf8'); | | 15 | +const toc = fs.readFileSync(source + '/index.html', 'utf8'); | 16 | 16 |
| 17 | 17 | // Extract (and concatenate) the toc and apicontent from each document. | 18 | 18 | let contents = ''; | @@ -47,11 +47,12 @@ for (const link of toc.match(/<a.*?>/g)) { | 47 | 47 | seen[href] = true; | 48 | 48 | } | 49 | 49 |
| 50 | | -// Replace various mentions of _toc with all. | 51 | | -let all = toc.replace(/_toc\.html/g, 'all.html') | 52 | | - .replace('_toc.json', 'all.json') | 53 | | - .replace('api-section-_toc', 'api-section-all') | 54 | | - .replace('data-id="_toc"', 'data-id="all"'); | | 50 | +// Replace various mentions of index with all. | | 51 | +let all = toc.replace(/index\.html/g, 'all.html') | | 52 | + .replace('<a href="all.html" name="toc">', '<a href="index.html" name="toc">') | | 53 | + .replace('index.json', 'all.json') | | 54 | + .replace('api-section-index', 'api-section-all') | | 55 | + .replace('data-id="index"', 'data-id="all"'); | 55 | 56 |
| 56 | 57 | // Clean up the title. | 57 | 58 | all = all.replace(/<title>.*?\| /, '<title>'); | |
|