Skip to content

Commit c38f101

Browse files
committed
chore(docs): remove old generated placeholders
1 parent 08550f1 commit c38f101

File tree

4 files changed

+17
-531
lines changed

4 files changed

+17
-531
lines changed

docs/lib/tags.js

Lines changed: 0 additions & 36 deletions
This file was deleted.

docs/lib/transform.js

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
const marked = require('marked-man')
22
const { join } = require('path')
3-
const TAGS = require('./tags')
43
const NPM = require('./npm.js')
54
const transformHTML = require('./transform-html.js')
65

6+
const TAGS = {
7+
CONFIG: '<!-- AUTOGENERATED CONFIG DESCRIPTIONS -->',
8+
USAGE: '<!-- AUTOGENERATED USAGE DESCRIPTIONS -->',
9+
SHORTHANDS: '<!-- AUTOGENERATED CONFIG SHORTHANDS -->',
10+
}
11+
712
const assertPlaceholder = (src, path, type) => {
8-
const placeholder = TAGS[type].REPLACE
13+
const placeholder = TAGS[type]
914
if (!src.includes(placeholder)) {
1015
throw new Error(
1116
`Cannot replace ${type} in ${path} due to missing placeholder`
@@ -20,15 +25,9 @@ const removePlaceholders = (src) => src.replace(/^<!--.*-->$/gm, '')
2025

2126
const replaceUsage = (src, { path, docExt }) => {
2227
const replacer = assertPlaceholder(src, path, 'USAGE')
23-
const { usage, name, srcName } = NPM.getCommandByDoc(path, docExt)
28+
const { usage, name } = NPM.getCommandByDoc(path, docExt)
2429

25-
const synopsis = [
26-
TAGS.USAGE.START,
27-
TAGS.USAGE.SEP(srcName),
28-
'',
29-
'```bash',
30-
usage,
31-
]
30+
const synopsis = ['```bash', usage]
3231

3332
const cmdAliases = Object.keys(NPM.aliases).reduce((p, c) => {
3433
if (NPM.aliases[c] === name) {
@@ -45,7 +44,7 @@ const replaceUsage = (src, { path, docExt }) => {
4544
synopsis.push(`aliases: ${cmdAliases.join(', ')}`)
4645
}
4746

48-
synopsis.push('```', '', TAGS.USAGE.SEP(srcName), '', TAGS.USAGE.END)
47+
synopsis.push('```')
4948

5049
return src.replace(replacer, synopsis.join('\n'))
5150
}
@@ -58,38 +57,18 @@ const replaceParams = (src, { path, docExt }) => {
5857
return src
5958
}
6059

61-
const config = [
62-
TAGS.CONFIG.START,
63-
TAGS.CONFIG.SEP(),
64-
NPM.describeParams(params).join('\n\n' + TAGS.CONFIG.SEP() + '\n\n'),
65-
'',
66-
TAGS.CONFIG.SEP(),
67-
'',
68-
TAGS.CONFIG.END,
69-
].join('\n')
70-
71-
return src.replace(replacer, config)
60+
return src.replace(replacer, NPM.describeParams(params).join('\n\n'))
7261
}
7362

7463
const replaceConfig = (src, { path }) => {
7564
const replacer = assertPlaceholder(src, path, 'CONFIG')
76-
77-
const config = [
78-
TAGS.CONFIG.START,
79-
TAGS.CONFIG.SEP(),
80-
NPM.describeAll(),
81-
'',
82-
TAGS.CONFIG.SEP(),
83-
TAGS.CONFIG.END,
84-
].join('\n')
85-
86-
return src.replace(replacer, config)
65+
return src.replace(replacer, NPM.describeAll())
8766
}
8867

8968
const replaceShorthands = (src, { path }) => {
9069
const replacer = assertPlaceholder(src, path, 'SHORTHANDS')
9170

92-
const sh = Object.entries(NPM.shorthands)
71+
const shorthands = Object.entries(NPM.shorthands)
9372
.sort(([shorta, expansiona], [shortb, expansionb]) => {
9473
// sort by what they're short FOR
9574
return expansiona.join(' ').localeCompare(expansionb.join(' '), 'en') ||
@@ -98,16 +77,9 @@ const replaceShorthands = (src, { path }) => {
9877
.map(([short, expansion]) => {
9978
const dash = short.length === 1 ? '-' : '--'
10079
return `* \`${dash}${short}\`: \`${expansion.join(' ')}\``
101-
}).join('\n')
102-
103-
return src.replace(replacer, [
104-
TAGS.SHORTHANDS.START,
105-
TAGS.SHORTHANDS.SEP(),
106-
sh,
107-
'',
108-
TAGS.SHORTHANDS.SEP(),
109-
TAGS.SHORTHANDS.END,
110-
].join('\n'))
80+
})
81+
82+
return src.replace(replacer, shorthands.join('\n'))
11183
}
11284

11385
const replaceHelpLinks = (src) => {

lib/utils/config/describe-all.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ const describeAll = () => {
1212
}
1313
return Object.entries(definitions).sort(sort)
1414
.map(([key, def]) => def.describe())
15-
.join(
16-
'\n\n<!-- automatically generated, do not edit manually -->\n' +
17-
'<!-- see lib/utils/config/definitions.js -->\n\n'
18-
)
15+
.join('\n\n')
1916
}
2017
module.exports = describeAll

0 commit comments

Comments
 (0)