Skip to content

Commit 882172f

Browse files
committed
put the make doc part in Makefile
1 parent 48e3b30 commit 882172f

File tree

2 files changed

+32
-45
lines changed

2 files changed

+32
-45
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ else
200200
test: all
201201
$(MAKE) build-addons
202202
$(MAKE) build-addons-napi
203+
$(MAKE) doc-only
203204
$(MAKE) cctest
204205
$(PYTHON) tools/test.py --mode=release -J \
205206
$(CI_ASYNC_HOOKS) \
@@ -379,7 +380,7 @@ test-ci-js: | clear-stalled
379380
fi
380381

381382
test-ci: LOGLEVEL := info
382-
test-ci: | clear-stalled build-addons build-addons-napi
383+
test-ci: | clear-stalled build-addons build-addons-napi doc-only
383384
out/Release/cctest --gtest_output=tap:cctest.tap
384385
$(PYTHON) tools/test.py $(PARALLEL_ARGS) -p tap --logfile test.tap \
385386
--mode=release --flaky-tests=$(FLAKY_TESTS) \

test/sequential/test-make-doc.js

Lines changed: 30 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,46 @@
11
'use strict';
22

3+
// This tests that `make doc` generates the documentation properly.
4+
// Note that for this test to pass, `make doc` must be run first.
5+
36
const common = require('../common');
47

58
const assert = require('assert');
6-
const exec = require('child_process').exec;
79
const fs = require('fs');
810
const path = require('path');
911

1012
if (common.isWindows) {
1113
common.skip('Do not make doc on Windows');
1214
}
1315

14-
// Make sure all the relative links work and
15-
// all the generated documents are linked in TOC
16-
function verifyToc() {
17-
const apiPath = path.join(common.projectDir, 'out', 'doc', 'api');
18-
const docs = fs.readdirSync(apiPath);
19-
assert.notStrictEqual(docs.indexOf('_toc.html'), -1);
20-
21-
const toc = fs.readFileSync(path.join(apiPath, '_toc.html'), 'utf8');
22-
const re = /href="([^/]+\.html)"/;
23-
const globalRe = new RegExp(re, 'g');
24-
const links = toc.match(globalRe);
25-
assert.notStrictEqual(links, null);
26-
27-
const linkedHtmls = links.map((link) => link.match(re)[1]);
28-
for (const html of linkedHtmls) {
29-
assert.notStrictEqual(docs.indexOf(html), -1, `${html} does not exist`);
30-
}
16+
const apiPath = path.join(common.projectDir, 'out', 'doc', 'api');
17+
const docs = fs.readdirSync(apiPath);
18+
assert.ok(docs.includes('_toc.html'));
19+
20+
const toc = fs.readFileSync(path.join(apiPath, '_toc.html'), 'utf8');
21+
const re = /href="([^/]+\.html)"/;
22+
const globalRe = new RegExp(re, 'g');
23+
const links = toc.match(globalRe);
24+
assert.notStrictEqual(links, null);
25+
26+
// Test that all the relative links in the TOC of the documentation
27+
// work and all the generated documents are linked in TOC.
28+
const linkedHtmls = links.map((link) => link.match(re)[1]);
29+
for (const html of linkedHtmls) {
30+
assert.ok(docs.includes(html), `${html} does not exist`);
31+
}
3132

32-
const excludes = ['.json', '_toc', 'assets'];
33-
const generatedHtmls = docs.filter(function(doc) {
34-
for (const exclude of excludes) {
35-
if (doc.includes(exclude)) {
36-
return false;
37-
}
33+
const excludes = ['.json', '_toc', 'assets'];
34+
const generatedHtmls = docs.filter(function(doc) {
35+
for (const exclude of excludes) {
36+
if (doc.includes(exclude)) {
37+
return false;
3838
}
39-
return true;
40-
});
41-
42-
for (const html of generatedHtmls) {
43-
assert.notStrictEqual(
44-
linkedHtmls.indexOf(html),
45-
-1,
46-
`${html} is not linked in toc`);
4739
}
48-
}
40+
return true;
41+
});
4942

50-
exec('make doc', {
51-
cwd: common.projectDir
52-
}, common.mustCall(function onExit(err, stdout, stderr) {
53-
console.log(stdout);
54-
if (stderr.length > 0) {
55-
console.log('stderr is not empty: ');
56-
console.log(stderr);
57-
}
58-
assert.ifError(err);
59-
verifyToc();
60-
}));
43+
for (const html of generatedHtmls) {
44+
assert.ok(linkedHtmls.includes(html), `${html} is not linked in toc`);
45+
}
46+

0 commit comments

Comments
 (0)