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 9093392

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

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
@@ -531,49 +531,68 @@ endif
531531
# generated .html files
532532
DOCS_ANALYTICS ?=
533533

534+
apidoc_dirs = out/doc out/doc/api out/doc/api/assets
534535
apidoc_sources = $(wildcard doc/api/*.md)
535-
apidocs_html = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.html))
536-
apidocs_json = $(apidoc_dirs) $(apiassets) $(addprefix out/,$(apidoc_sources:.md=.json))
537-
538-
apidoc_dirs = out/doc out/doc/api/ out/doc/api/assets
536+
apidocs_html = $(addprefix out/,$(apidoc_sources:.md=.html))
537+
apidocs_json = $(addprefix out/,$(apidoc_sources:.md=.json))
539538

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

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

546-
$(apidoc_dirs):
547-
@mkdir -p $@
552+
out/doc:
553+
mkdir -p $@
554+
555+
# If it's a source tarball, doc/api already contains the generated docs.
556+
# Just copy everything under doc/api over.
557+
out/doc/api: doc/api
558+
mkdir -p $@
559+
cp -r doc/api out/doc
548560

561+
# If it's a source tarball, assets are already in doc/api/assets
562+
out/doc/api/assets:
563+
mkdir -p $@
564+
if [ -d doc/api/assets ]; then cp -r doc/api/assets out/doc/api; fi;
565+
566+
# If it's not a source tarball, we need to copy assets from doc/api_assets
549567
out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets
550568
@cp $< $@
551569

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

555-
# check if ./node is actually set, else use user pre-installed binary
556587
gen-json = tools/doc/generate.js --format=json $< > $@
557588
gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \
558589
--template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@
559590

560-
install-yaml:
561-
[ -e tools/doc/node_modules/js-yaml/package.json ] || \
562-
[ -e tools/eslint/node_modules/js-yaml/package.json ] || \
563-
if [ -x $(NODE) ]; then \
564-
cd tools/doc && ../../$(NODE) ../../$(NPM) install; \
565-
else \
566-
cd tools/doc && node ../../$(NPM) install; \
567-
fi;
568-
569-
gen-doc = [ -x $(NODE) ] && $(NODE) $(1) || node $(1)
570-
571591
out/doc/api/%.json: doc/api/%.md
572-
@$(call gen-doc, $(gen-json))
592+
$(call available-node, $(gen-json))
573593

574-
# check if ./node is actually set, else use user pre-installed binary
575594
out/doc/api/%.html: doc/api/%.md
576-
@$(call gen-doc, $(gen-html))
595+
$(call available-node, $(gen-html))
577596

578597
docopen: $(apidocs_html)
579598
@$(PYTHON) -mwebbrowser file://$(PWD)/out/doc/api/all.html
@@ -1152,7 +1171,6 @@ lint-clean:
11521171
install \
11531172
install-bin \
11541173
install-includes \
1155-
install-yaml \
11561174
lint \
11571175
lint-clean \
11581176
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.