Skip to content

Commit 6032dc2

Browse files
jmmevanlucas
authored andcommitted
build: add Make doc-only target
Allows building just docs using existing Node instead of building Node first. PR-URL: #3888 Reviewed-By: Chris Dickinson <[email protected]> Reviewed-By: Rod Vagg <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Myles Borins <[email protected]>
1 parent 6eed6a3 commit 6032dc2

File tree

4 files changed

+49
-15
lines changed

4 files changed

+49
-15
lines changed

‎BUILDING.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,20 @@ $ make test
5252

5353
To build the documentation:
5454

55+
This will build Node.js first (if necessary) and then use it to build the docs:
56+
5557
```text
5658
$ make doc
5759
```
5860

61+
If you have an existing Node.js you can build just the docs with:
62+
63+
```text
64+
$ NODE=node make doc-only
65+
```
66+
67+
(Where `node` is the path to your executable.)
68+
5969
To read the documentation:
6070

6171
```text

‎Makefile‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ BUILDTYPE_LOWER := $(shell echo $(BUILDTYPE) | tr '[A-Z]' '[a-z]')
3636
EXEEXT := $(shell$(PYTHON) -c \
3737
"import sys; print('.exe' if sys.platform == 'win32' else '')")
3838

39-
NODE ?= ./node$(EXEEXT)
4039
NODE_EXE = node$(EXEEXT)
40+
NODE ?= ./$(NODE_EXE)
4141
NODE_G_EXE = node_g$(EXEEXT)
4242

4343
# Flags for packaging.
@@ -260,7 +260,9 @@ apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
260260

261261
apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*)))
262262

263-
doc: $(apidoc_dirs)$(apiassets)$(apidocs) tools/doc/ $(NODE_EXE)
263+
doc-only: $(apidoc_dirs)$(apiassets)$(apidocs) tools/doc/
264+
265+
doc: $(NODE_EXE) doc-only
264266

265267
$(apidoc_dirs):
266268
mkdir -p $@
@@ -271,11 +273,11 @@ out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets/
271273
out/doc/%: doc/%
272274
cp -r $<$@
273275

274-
out/doc/api/%.json: doc/api/%.md$(NODE_EXE)
276+
out/doc/api/%.json: doc/api/%.md
275277
$(NODE) tools/doc/generate.js --format=json $<>$@
276278

277-
out/doc/api/%.html: doc/api/%.md$(NODE_EXE)
278-
$(NODE) tools/doc/generate.js --format=html --template=doc/template.html $<>$@
279+
out/doc/api/%.html: doc/api/%.md
280+
$(NODE) tools/doc/generate.js --node-version=$(FULLVERSION) --format=html --template=doc/template.html $<>$@
279281

280282
docopen: out/doc/api/all.html
281283
-google-chrome out/doc/api/all.html
@@ -694,5 +696,5 @@ endif
694696
blog blogclean tar binary release-only bench-http-simple bench-idle \
695697
bench-all bench bench-misc bench-array bench-buffer bench-net \
696698
bench-http bench-fs bench-tls cctest run-ci test-v8 test-v8-intl \
697-
test-v8-benchmarks test-v8-all v8 lint-ci bench-ci jslint-ci \
699+
test-v8-benchmarks test-v8-all v8 lint-ci bench-ci jslint-ci doc-only \
698700
$(TARBALL)-headers

‎tools/doc/generate.js‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const args = process.argv.slice(2);
1010
letformat='json';
1111
lettemplate=null;
1212
letinputFile=null;
13+
letnodeVersion=null;
1314

1415
args.forEach(function(arg){
1516
if(!arg.match(/^\-\-/)){
@@ -18,23 +19,22 @@ args.forEach(function(arg){
1819
format=arg.replace(/^\-\-format=/,'');
1920
}elseif(arg.match(/^\-\-template=/)){
2021
template=arg.replace(/^\-\-template=/,'');
22+
}elseif(arg.match(/^\-\-node\-version=/)){
23+
nodeVersion=arg.replace(/^\-\-node\-version=/,'');
2124
}
2225
});
2326

24-
2527
if(!inputFile){
2628
thrownewError('No input file specified');
2729
}
2830

29-
3031
console.error('Input file = %s',inputFile);
3132
fs.readFile(inputFile,'utf8',function(er,input){
3233
if(er)thrower;
3334
// process the input for @include lines
3435
processIncludes(inputFile,input,next);
3536
});
3637

37-
3838
functionnext(er,input){
3939
if(er)thrower;
4040
switch(format){
@@ -46,7 +46,12 @@ function next(er, input){
4646
break;
4747

4848
case'html':
49-
require('./html.js')(input,inputFile,template,function(er,html){
49+
require('./html.js')({
50+
input: input,
51+
filename: inputFile,
52+
template: template,
53+
nodeVersion: nodeVersion,
54+
},function(er,html){
5055
if(er)thrower;
5156
console.log(html);
5257
});

‎tools/doc/html.js‎

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,12 @@ var gtocPath = path.resolve(path.join(
3030
vargtocLoading=null;
3131
vargtocData=null;
3232

33-
functiontoHTML(input,filename,template,cb){
33+
/**
34+
* opts: input, filename, template, nodeVersion.
35+
*/
36+
functiontoHTML(opts,cb){
37+
vartemplate=opts.template;
38+
3439
if(gtocData){
3540
returnonGtocLoaded();
3641
}
@@ -51,10 +56,15 @@ function toHTML(input, filename, template, cb){
5156
}
5257

5358
functiononGtocLoaded(){
54-
varlexed=marked.lexer(input);
59+
varlexed=marked.lexer(opts.input);
5560
fs.readFile(template,'utf8',function(er,template){
5661
if(er)returncb(er);
57-
render(lexed,filename,template,cb);
62+
render({
63+
lexed: lexed,
64+
filename: opts.filename,
65+
template: template,
66+
nodeVersion: opts.nodeVersion,
67+
},cb);
5868
});
5969
}
6070
}
@@ -81,7 +91,14 @@ function toID(filename){
8191
.replace(/-+/g,'-');
8292
}
8393

84-
functionrender(lexed,filename,template,cb){
94+
/**
95+
* opts: lexed, filename, template, nodeVersion.
96+
*/
97+
functionrender(opts,cb){
98+
varlexed=opts.lexed;
99+
varfilename=opts.filename;
100+
vartemplate=opts.template;
101+
85102
// get the section
86103
varsection=getSection(lexed);
87104

@@ -100,7 +117,7 @@ function render(lexed, filename, template, cb){
100117
template=template.replace(/__ID__/g,id);
101118
template=template.replace(/__FILENAME__/g,filename);
102119
template=template.replace(/__SECTION__/g,section);
103-
template=template.replace(/__VERSION__/g,process.version);
120+
template=template.replace(/__VERSION__/g,opts.nodeVersion);
104121
template=template.replace(/__TOC__/g,toc);
105122
template=template.replace(
106123
/__GTOC__/g,

0 commit comments

Comments
(0)