Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2c62ff9

Browse filesBrowse files
joyeecheunggibfahn
authored andcommitted
build: do not build doc in source tarball
PR-URL: #17100 Fixes: #16650 Reviewed-By: Refael Ackermann <refack@gmail.com>
1 parent be088b9 commit 2c62ff9
Copy full SHA for 2c62ff9

File tree

Expand file treeCollapse file tree

2 files changed

+45
-27
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+45
-27
lines changed
Open diff view settings
Collapse file

‎Makefile‎

Copy file name to clipboardExpand all lines: Makefile
+44-26Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -536,49 +536,68 @@ endif
536536
# generated .html files
537537
DOCS_ANALYTICS ?=
538538

539+
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
539540
apidoc_sources = $(wildcard doc/api/*.md)
540-
apidocs_html = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.html))
541-
apidocs_json = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.json))
542-
543-
apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
541+
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
542+
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
544543

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

547-
doc-targets: $(apidocs_html) $(apidocs_json)
548-
doc-only: | install-yaml doc-targets
546+
# This uses the locally built node if available, otherwise uses the global node
547+
doc-only: $(apidoc_dirs) $(apiassets)
548+
# If it's a source tarball, assets are already in doc/api/assets,
549+
# no need to install anything, we have already copied the docs over
550+
if [ ! -d doc/api/assets ]; then \
551+
$(MAKE) tools/doc/node_modules/js-yaml/package.json; \
552+
fi;
553+
@$(MAKE) -s $(apidocs_html) $(apidocs_json)
554+
549555
doc: $(NODE_EXE) doc-only
550556

551-
$(apidoc_dirs):
552-
@mkdir -p $@
557+
out/doc:
558+
mkdir -p $@
559+
560+
# If it's a source tarball, doc/api already contains the generated docs.
561+
# Just copy everything under doc/api over.
562+
out/doc/api: doc/api
563+
mkdir -p $@
564+
cp -r doc/api out/doc
553565

566+
# If it's a source tarball, assets are already in doc/api/assets
567+
out/doc/api/assets:
568+
mkdir -p $@
569+
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
570+
571+
# If it's not a source tarball, we need to copy assets from doc/api_assets
554572
out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
555573
@cp $< $@
556574

557-
out/doc/%: doc/%
558-
@cp -r $< $@
575+
# Use -e to double check in case it's a broken link
576+
# Use $(PWD) so we can cd to anywhere before calling this
577+
available-node = \
578+
if [ -x $(PWD)/$(NODE) ] && [ -e $(PWD)/$(NODE) ]; then \
579+
$(PWD)/$(NODE) $(1); \
580+
elif [ -x `which node` ] && [ -e `which node` ]; then \
581+
`which node` $(1); \
582+
else \
583+
echo "No available node, cannot run \"node $(1)\""; \
584+
exit 1; \
585+
fi;
586+
587+
run-npm-install = $(PWD)/$(NPM) install
588+
589+
tools/doc/node_modules/js-yaml/package.json:
590+
cd tools/doc && $(call available-node,$(run-npm-install))
559591

560-
# check if ./node is actually set, else use user pre-installed binary
561592
gen-json = tools/doc/generate.js --format=json $< > $@
562593
gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \
563594
--template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@
564595

565-
install-yaml:
566-
[ -e tools/doc/node_modules/js-yaml/package.json ] || \
567-
[ -e tools/eslint/node_modules/js-yaml/package.json ] || \
568-
if [ -x $(NODE) ]; then \
569-
cd tools/doc && ../../$(NODE) ../../$(NPM) install; \
570-
else \
571-
cd tools/doc && node ../../$(NPM) install; \
572-
fi;
573-
574-
gen-doc = [ -x $(NODE) ] && $(NODE) $(1) || node $(1)
575-
576596
out/doc/api/%.json: doc/api/%.md
577-
@$(call gen-doc, $(gen-json))
597+
$(call available-node, $(gen-json))
578598

579-
# check if ./node is actually set, else use user pre-installed binary
580599
out/doc/api/%.html: doc/api/%.md
581-
@$(call gen-doc, $(gen-html))
600+
$(call available-node, $(gen-html))
582601

583602
docopen: $(apidocs_html)
584603
@$(PYTHON) -mwebbrowser file://$(PWD)/out/doc/api/all.html
@@ -1157,7 +1176,6 @@ lint-clean:
11571176
install \
11581177
install-bin \
11591178
install-includes \
1160-
install-yaml \
11611179
lint \
11621180
lint-clean \
11631181
lint-ci \
Collapse file

‎test/doctool/test-make-doc.js‎

Copy file name to clipboardExpand all lines: test/doctool/test-make-doc.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ for (const html of linkedHtmls) {
2828
assert.ok(docs.includes(html), `${html} does not exist`);
2929
}
3030

31-
const excludes = ['.json', '_toc', 'assets'];
31+
const excludes = ['.json', '.md', '_toc', 'assets'];
3232
const generatedHtmls = docs.filter(function(doc) {
3333
for (const exclude of excludes) {
3434
if (doc.includes(exclude)) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.