@redpanda-data/docs-extensions-and-macros 5.42.0 → 5.44.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/doc-tools.js
CHANGED
|
@@ -1476,6 +1476,9 @@ automation
|
|
|
1476
1476
|
* parsing `-X list` text for rpk versions that predate it. Hidden -X options
|
|
1477
1477
|
* appear in neither source, so they are excluded automatically.
|
|
1478
1478
|
*
|
|
1479
|
+
* The table is sectioned by the API group rpk reports for each option, and is
|
|
1480
|
+
* a single flat table on rpk versions that report no groups.
|
|
1481
|
+
*
|
|
1479
1482
|
* The main rpk-docs pipeline also writes this partial from the tree it
|
|
1480
1483
|
* already holds; this standalone command is for targeted refreshes without
|
|
1481
1484
|
* a full generation run.
|
|
@@ -1492,7 +1495,7 @@ automation
|
|
|
1492
1495
|
*/
|
|
1493
1496
|
automation
|
|
1494
1497
|
.command('rpk-env-partial')
|
|
1495
|
-
.description('Generate the -X -> RPK_* env var mapping partial from rpk
|
|
1498
|
+
.description('Generate the -X -> RPK_* env var mapping partial from rpk itself.')
|
|
1496
1499
|
.option('-r, --ref <ref>', 'Git branch or tag to build rpk from (e.g., dev, v26.2.1). Clones from GitHub.')
|
|
1497
1500
|
.option('--from-source <path>', 'Path to local rpk source (src/go/rpk directory)')
|
|
1498
1501
|
.option('--rpk-bin <path>', 'Path to an existing rpk binary (skips clone and build)')
|
package/package.json
CHANGED
|
@@ -3227,7 +3227,11 @@ function writeEnvVarsPartial (tree, partialsDir) {
|
|
|
3227
3227
|
return { written: false }
|
|
3228
3228
|
}
|
|
3229
3229
|
const { renderPartial, keyToEnvVar } = require('./generate-x-env-partial.js')
|
|
3230
|
-
const options = tree.x_options.map(o => ({
|
|
3230
|
+
const options = tree.x_options.map(o => ({
|
|
3231
|
+
name: o.name,
|
|
3232
|
+
env: o.env || keyToEnvVar(o.name),
|
|
3233
|
+
groupTitle: o.group_title || null
|
|
3234
|
+
}))
|
|
3231
3235
|
const output = path.join(partialsDir, 'rpk-env-vars.adoc')
|
|
3232
3236
|
fs.mkdirSync(path.dirname(output), { recursive: true })
|
|
3233
3237
|
fs.writeFileSync(output, renderPartial(options))
|
|
@@ -11,6 +11,12 @@
|
|
|
11
11
|
* descriptions.
|
|
12
12
|
* 2. `rpk -X list` text output, for rpk versions that predate x_options.
|
|
13
13
|
*
|
|
14
|
+
* Each x_option also carries the API it configures, as `group` (a stable
|
|
15
|
+
* slug) and `group_title` (the heading), added in
|
|
16
|
+
* redpanda-data/streaming-enterprise#311. When rpk supplies them the table is
|
|
17
|
+
* sectioned by API, so the grouping comes from rpk rather than being restated
|
|
18
|
+
* here; rpk versions without them get one flat table.
|
|
19
|
+
*
|
|
14
20
|
* The partial is included by both reference:rpk/rpk-x-options.adoc and
|
|
15
21
|
* reference:environment-variables.adoc in the docs repo. Hidden -X options
|
|
16
22
|
* (for example cloud_environment, whose values are deliberately
|
|
@@ -38,10 +44,12 @@ const GENERATED_BANNER = `// tag::generated[]
|
|
|
38
44
|
/**
|
|
39
45
|
* Extract -X options from `rpk --print-tree` JSON.
|
|
40
46
|
* @param {string} output - Raw stdout from `rpk --print-tree`
|
|
41
|
-
* @returns {Array<{name: string, env: string}>|null}
|
|
42
|
-
* order, or null when the tree has no x_options (rpk
|
|
43
|
-
* redpanda#31520). The env name comes from rpk itself when present
|
|
47
|
+
* @returns {Array<{name: string, env: string, group: ?string, groupTitle: ?string}>|null}
|
|
48
|
+
* options in display order, or null when the tree has no x_options (rpk
|
|
49
|
+
* predates redpanda#31520). The env name comes from rpk itself when present
|
|
44
50
|
* (the tree's env field is produced by the same derivation rpk reads).
|
|
51
|
+
* group and groupTitle are null on rpk versions that do not group the
|
|
52
|
+
* options.
|
|
45
53
|
*/
|
|
46
54
|
function xOptionsFromTree (output) {
|
|
47
55
|
let tree
|
|
@@ -51,7 +59,12 @@ function xOptionsFromTree (output) {
|
|
|
51
59
|
return null
|
|
52
60
|
}
|
|
53
61
|
if (!Array.isArray(tree.x_options) || tree.x_options.length === 0) return null
|
|
54
|
-
return tree.x_options.map(o => ({
|
|
62
|
+
return tree.x_options.map(o => ({
|
|
63
|
+
name: o.name,
|
|
64
|
+
env: o.env || keyToEnvVar(o.name),
|
|
65
|
+
group: o.group || null,
|
|
66
|
+
groupTitle: o.group_title || null
|
|
67
|
+
}))
|
|
55
68
|
}
|
|
56
69
|
|
|
57
70
|
/**
|
|
@@ -96,16 +109,53 @@ function keyToAnchor (key) {
|
|
|
96
109
|
return key.replace(/\./g, '-')
|
|
97
110
|
}
|
|
98
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Group options by the API group rpk reports, in first-seen order.
|
|
114
|
+
*
|
|
115
|
+
* Returns null unless every option carries a group title, so a table is
|
|
116
|
+
* either fully sectioned or not sectioned at all: a half-sectioned table
|
|
117
|
+
* would read as though the options with no heading belonged to the section
|
|
118
|
+
* above them.
|
|
119
|
+
*
|
|
120
|
+
* Grouping by title rather than slicing on the boundaries means a group whose
|
|
121
|
+
* options are not contiguous still gets one heading instead of two.
|
|
122
|
+
* @param {Array<{name: string, env: string, groupTitle: ?string}>} options
|
|
123
|
+
* @returns {Array<{title: string, options: Array<Object>}>|null}
|
|
124
|
+
*/
|
|
125
|
+
function groupOptions (options) {
|
|
126
|
+
if (!options.every(o => o.groupTitle)) return null
|
|
127
|
+
const byTitle = new Map()
|
|
128
|
+
for (const option of options) {
|
|
129
|
+
const existing = byTitle.get(option.groupTitle)
|
|
130
|
+
if (existing) existing.push(option)
|
|
131
|
+
else byTitle.set(option.groupTitle, [option])
|
|
132
|
+
}
|
|
133
|
+
return [...byTitle].map(([title, opts]) => ({ title, options: opts }))
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Render one table row for an option.
|
|
138
|
+
* @param {{name: string, env: string}} option
|
|
139
|
+
* @returns {string}
|
|
140
|
+
*/
|
|
141
|
+
function renderRow ({ name, env }) {
|
|
142
|
+
return `|xref:reference:rpk/rpk-x-options.adoc#${keyToAnchor(name)}[${name}] |${env}`
|
|
143
|
+
}
|
|
144
|
+
|
|
99
145
|
/**
|
|
100
146
|
* Render the partial's AsciiDoc content.
|
|
101
|
-
*
|
|
147
|
+
*
|
|
148
|
+
* The table is sectioned by API group when rpk reports one for every option,
|
|
149
|
+
* and is a single flat table otherwise (rpk versions that predate the groups,
|
|
150
|
+
* and the -X list fallback, which has no group data to parse).
|
|
151
|
+
* @param {Array<{name: string, env: string, groupTitle: ?string}>} options - -X options
|
|
102
152
|
* @returns {string}
|
|
103
153
|
*/
|
|
104
154
|
function renderPartial (options) {
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
155
|
+
const groups = groupOptions(options)
|
|
156
|
+
const body = groups
|
|
157
|
+
? groups.map(g => `2+s|${g.title}\n${g.options.map(renderRow).join('\n')}`).join('\n\n')
|
|
158
|
+
: options.map(renderRow).join('\n')
|
|
109
159
|
return `${GENERATED_BANNER}
|
|
110
160
|
Every \`-X\` option has a corresponding \`RPK_*\` environment variable. Convert by prefixing with \`RPK_\` and replacing dots with underscores:
|
|
111
161
|
|
|
@@ -113,7 +163,7 @@ Every \`-X\` option has a corresponding \`RPK_*\` environment variable. Convert
|
|
|
113
163
|
|===
|
|
114
164
|
|\`-X\` Option |Environment Variable
|
|
115
165
|
|
|
116
|
-
${
|
|
166
|
+
${body}
|
|
117
167
|
|===
|
|
118
168
|
// end::generated[]
|
|
119
169
|
`
|
|
@@ -276,6 +326,7 @@ function handleXEnvPartialGeneration (options) {
|
|
|
276
326
|
|
|
277
327
|
module.exports = {
|
|
278
328
|
xOptionsFromTree,
|
|
329
|
+
groupOptions,
|
|
279
330
|
parseXList,
|
|
280
331
|
keyToEnvVar,
|
|
281
332
|
keyToAnchor,
|