| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -531,49 +531,68 @@ endif | |||
| 531 | 531 | # generated .html files | |
| 532 | 532 | DOCS_ANALYTICS ?= | |
| 533 | 533 | ||
| 534 | + apidoc_dirs = out/doc out/doc/api out/doc/api/assets | ||
| 534 | 535 | 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)) | ||
| 539 | 538 | ||
| 540 | 539 | apiassets = $(subst api_assets,api/assets,$(addprefix out/,$(wildcard doc/api_assets/*))) | |
| 541 | 540 | ||
| 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 | + | ||
| 544 | 550 | doc: $(NODE_EXE) doc-only | |
| 545 | 551 | ||
| 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 | ||
| 548 | 560 | ||
| 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 | ||
| 549 | 567 | out/doc/api/assets/%: doc/api_assets/% out/doc/api/assets | |
| 550 | 568 | @cp $< $@ | |
| 551 | 569 | ||
| 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)) | ||
| 554 | 586 | ||
| 555 | - # check if ./node is actually set, else use user pre-installed binary | ||
| 556 | 587 | gen-json = tools/doc/generate.js --format=json $< > $@ | |
| 557 | 588 | gen-html = tools/doc/generate.js --node-version=$(FULLVERSION) --format=html \ | |
| 558 | 589 | --template=doc/template.html --analytics=$(DOCS_ANALYTICS) $< > $@ | |
| 559 | 590 | ||
| 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 | - | ||
| 571 | 591 | out/doc/api/%.json: doc/api/%.md | |
| 572 | - @$(call gen-doc, $(gen-json)) | ||
| 592 | + $(call available-node, $(gen-json)) | ||
| 573 | 593 | ||
| 574 | - # check if ./node is actually set, else use user pre-installed binary | ||
| 575 | 594 | out/doc/api/%.html: doc/api/%.md | |
| 576 | - @$(call gen-doc, $(gen-html)) | ||
| 595 | + $(call available-node, $(gen-html)) | ||
| 577 | 596 | ||
| 578 | 597 | docopen: $(apidocs_html) | |
| 579 | 598 | @$(PYTHON) -mwebbrowser file://$(PWD)/out/doc/api/all.html | |
@@ -1152,7 +1171,6 @@ lint-clean: | |||
| 1152 | 1171 | install \ | |
| 1153 | 1172 | install-bin \ | |
| 1154 | 1173 | install-includes \ | |
| 1155 | - install-yaml \ | ||
| 1156 | 1174 | lint \ | |
| 1157 | 1175 | lint-clean \ | |
| 1158 | 1176 | lint-ci \ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,7 +28,7 @@ for (const html of linkedHtmls) { | |||
| 28 | 28 | assert.ok(docs.includes(html), `${html} does not exist`); | |
| 29 | 29 | } | |
| 30 | 30 | ||
| 31 | - const excludes = ['.json', '_toc', 'assets']; | ||
| 31 | + const excludes = ['.json', '.md', '_toc', 'assets']; | ||
| 32 | 32 | const generatedHtmls = docs.filter(function(doc) { | |
| 33 | 33 | for (const exclude of excludes) { | |
| 34 | 34 | if (doc.includes(exclude)) { | |
| Back | FazBrowse Home | New Git URL |
0 commit comments