-
-
Notifications
You must be signed in to change notification settings - Fork 33.8k
test: test make doc and verify toc #16208
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
Changes from 9 commits
d8cc63b
43ce6da
48e3b30
882172f
2ff4a77
271ff20
60c3c85
014e360
f678717
bdff9e3
2de566b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,45 @@ | ||||||||||||||||
| 'use strict'; | ||||||||||||||||
|
|
||||||||||||||||
| // This tests that `make doc` generates the documentation properly. | ||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nits: as per node/doc/guides/writing-tests.md Lines 26 to 32 in ff747e3
'use strict';
const common = require('../common');
if (common.isWindows) {
common.skip('Do not make doc on Windows');
}
// This tests that `make doc` generates the documentation properly.
// Note that for this test to pass, `make doc` must be run first.
const assert = require('assert');
const fs = require('fs');
const path = require('path'); |
||||||||||||||||
| // Note that for this test to pass, `make doc` must be run first. | ||||||||||||||||
|
|
||||||||||||||||
| const common = require('../common'); | ||||||||||||||||
|
|
||||||||||||||||
| const assert = require('assert'); | ||||||||||||||||
| const fs = require('fs'); | ||||||||||||||||
| const path = require('path'); | ||||||||||||||||
|
|
||||||||||||||||
| if (common.isWindows) { | ||||||||||||||||
| common.skip('Do not make doc on Windows'); | ||||||||||||||||
|
||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| const apiPath = path.join(common.projectDir, 'out', 'doc', 'api'); | ||||||||||||||||
| const docs = fs.readdirSync(apiPath); | ||||||||||||||||
| assert.ok(docs.includes('_toc.html')); | ||||||||||||||||
|
|
||||||||||||||||
| const toc = fs.readFileSync(path.join(apiPath, '_toc.html'), 'utf8'); | ||||||||||||||||
| const re = /href="([^/]+\.html)"/; | ||||||||||||||||
| const globalRe = new RegExp(re, 'g'); | ||||||||||||||||
| const links = toc.match(globalRe); | ||||||||||||||||
| assert.notStrictEqual(links, null); | ||||||||||||||||
|
|
||||||||||||||||
| // Test that all the relative links in the TOC of the documentation | ||||||||||||||||
| // work and all the generated documents are linked in TOC. | ||||||||||||||||
| const linkedHtmls = links.map((link) => link.match(re)[1]); | ||||||||||||||||
| for (const html of linkedHtmls) { | ||||||||||||||||
| assert.ok(docs.includes(html), `${html} does not exist`); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| const excludes = ['.json', '_toc', 'assets']; | ||||||||||||||||
| const generatedHtmls = docs.filter(function(doc) { | ||||||||||||||||
| for (const exclude of excludes) { | ||||||||||||||||
| if (doc.includes(exclude)) { | ||||||||||||||||
| return false; | ||||||||||||||||
| } | ||||||||||||||||
| } | ||||||||||||||||
| return true; | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| for (const html of generatedHtmls) { | ||||||||||||||||
| assert.ok(linkedHtmls.includes(html), `${html} is not linked in toc`); | ||||||||||||||||
| } | ||||||||||||||||
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.
Maybe
path.resolvethe output?