From cc36fca143132f9282b06d3de851f09c428a0fc1 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 5 Nov 2019 10:14:35 -0800 Subject: [PATCH 1/2] doc: Move @VERSION@ for html docs into gatsby --- Makefile | 4 +--- docs/src/templates/Page.js | 5 ++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index c1f3751b44687..11e656c43a458 100644 --- a/Makefile +++ b/Makefile @@ -52,8 +52,6 @@ htmldocs: cd docs && node ../bin/npm-cli.js install && \ node ../bin/npm-cli.js run build:static echo>&2 && \ rm -rf node_modules .cache public/*js public/*json public/404* public/page-data public/manifest* - find docs/public -name '*.html' -exec \ - node scripts/docs-build.js {} \; docs: mandocs htmldocs @@ -92,7 +90,7 @@ man/man1/npx.1: node_modules/libnpx/libnpx.1 man/man5/npm-json.5: man/man5/package.json.5 cp $< $@ -man/man5/npm-global.5: man/man5/foslders.5 +man/man5/npm-global.5: man/man5/folders.5 cp $< $@ man/man5/%.5: docs/content/configuring-npm/%.md scripts/docs-build.js package.json $(build-doc-tools) diff --git a/docs/src/templates/Page.js b/docs/src/templates/Page.js index a79abf1719ef3..bd7d6a01ca3b3 100644 --- a/docs/src/templates/Page.js +++ b/docs/src/templates/Page.js @@ -5,6 +5,7 @@ import styled, { ThemeProvider } from 'styled-components' import {theme} from 'src/theme' import FoundTypo from 'src/components/FoundTypo' import Scripts from 'src/components/Scripts' +const version = require('../../../package.json').version const Content = styled.div` max-width: 760px; @@ -20,7 +21,9 @@ const Page = ({data}) => { -
+
From 6757077b405610eaa2be7fd958f3cb457c99f432 Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 5 Nov 2019 10:22:35 -0800 Subject: [PATCH 2/2] doc: fix hyperlink refs in man page docs --- scripts/docs-build.js | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/scripts/docs-build.js b/scripts/docs-build.js index fd7d74f642a0a..f6b87ae9d0445 100644 --- a/scripts/docs-build.js +++ b/scripts/docs-build.js @@ -10,22 +10,17 @@ var dest = args[1] || src fs.readFile(src, 'utf8', function (err, data) { if (err) return console.log(err) - var fileExt = src.split('.').pop() var result = data.replace(/@VERSION@/g, npm.version) + .replace(/---([\s\S]+)---/g, '') + .replace(/(npm-)?([a-zA-Z\\.-]*)\(1\)/g, 'npm help $2') + .replace(/(npm-)?([a-zA-Z\\.-]*)\((5|7)\)/g, 'npm help $2') + .replace(/npm(1)/g, 'npm help npm') + .replace(/\[([^\]]+)\]\(\/cli-commands\/([^)]+)\)/g, 'npm help $2') + .replace(/\[([^\]]+)\]\(\/configuring-npm\/([^)]+)\)/g, 'npm help $2') + .replace(/\[([^\]]+)\]\(\/using-npm\/([^)]+)\)/g, 'npm help $2') + .trim() - if (fileExt === 'md') { - result = marked( - result.replace(/---([\s\S]+)---/g, '') - .replace(/(npm-)?([a-zA-Z\\.-]*)\(1\)/g, 'npm help $2') - .replace(/(npm-)?([a-zA-Z\\.-]*)\((5|7)\)/g, 'npm help $2') - .replace(/(npm-)?([a-zA-Z\\.-]*)\(3\)/g, 'npm apihelp $2') - .replace(/npm(1)/g, 'npm help npm') - .replace(/npm(3)/g, 'npm apihelp npm') - .trim() - ) - } - - fs.writeFile(dest, result, 'utf8', function (err) { + fs.writeFile(dest, marked(result), 'utf8', function (err) { if (err) return console.log(err) }) })