Skip to content

Commit 268303c

Browse files
authored
docs: add npm version to every local help output (#7479)
Every page of npm help <x> display the local npm version. This pull request helps the local reader of the documentation to know which version of the documentation they are reading. ## References Closes: #7110
1 parent 722c0fa commit 268303c

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

docs/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ const replaceHelpLinks = (src) => {
157157

158158
const transformMan = (src, { data, unified, remarkParse, remarkMan }) => unified()
159159
.use(remarkParse)
160-
.use(remarkMan)
160+
.use(remarkMan, { version: `NPM@${version}` })
161161
.processSync(`# ${data.title}(${data.section}) - ${data.description}\n\n${src}`)
162162
.toString()
163163

docs/lib/template.html

+9-1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@
115115
line-height: 1;
116116
}
117117

118+
header.title .version {
119+
font-size: 0.8em;
120+
color: #666666;
121+
}
122+
118123
footer#edit {
119124
border-top: solid 1px #e1e4e8;
120125
margin: 3em 0 4em 0;
@@ -138,7 +143,10 @@
138143

139144
<section id="content">
140145
<header class="title">
141-
<h1>{{ title }}</h1>
146+
<h1>
147+
<span>{{ title }}</span>
148+
<span class="version">@{{ version }}</span>
149+
</h1>
142150
<span class="description">{{ description }}</span>
143151
</header>
144152

docs/lib/transform-html.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const jsdom = require('jsdom')
2+
const { version } = require('../../package.json')
23

34
function transformHTML (
45
src,
@@ -36,6 +37,9 @@ function transformHTML (
3637
case 'config.github_path':
3738
return data[key.replace(/^config\./, '')]
3839

40+
case 'version':
41+
return version
42+
3943
default:
4044
throw new Error(`warning: unknown token '${token}' in ${path}`)
4145
}

0 commit comments

Comments
 (0)