@redpanda-data/docs-extensions-and-macros 4.4.0 → 4.4.2
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
|
@@ -5,6 +5,20 @@ const { Command } = require('commander');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
|
|
8
|
+
function findRepoRoot(start = process.cwd()) {
|
|
9
|
+
let dir = start;
|
|
10
|
+
while (dir !== path.parse(dir).root) {
|
|
11
|
+
// marker could be a .git folder or package.json or anything you choose
|
|
12
|
+
if (fs.existsSync(path.join(dir, '.git')) ||
|
|
13
|
+
fs.existsSync(path.join(dir, 'package.json'))) {
|
|
14
|
+
return dir;
|
|
15
|
+
}
|
|
16
|
+
dir = path.dirname(dir);
|
|
17
|
+
}
|
|
18
|
+
console.error('❌ Could not find repo root (no .git or package.json in any parent)');
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
|
|
8
22
|
// --------------------------------------------------------------------
|
|
9
23
|
// Dependency check functions
|
|
10
24
|
// --------------------------------------------------------------------
|
|
@@ -107,7 +121,7 @@ const programCli = new Command();
|
|
|
107
121
|
programCli
|
|
108
122
|
.name('doc-tools')
|
|
109
123
|
.description('Redpanda Document Automation CLI')
|
|
110
|
-
.version('1.0.
|
|
124
|
+
.version('1.0.1');
|
|
111
125
|
|
|
112
126
|
// Top-level commands.
|
|
113
127
|
programCli
|
|
@@ -295,6 +309,42 @@ automation
|
|
|
295
309
|
process.exit(0);
|
|
296
310
|
});
|
|
297
311
|
|
|
312
|
+
programCli
|
|
313
|
+
.command('link-readme')
|
|
314
|
+
.description('Symlink a README.adoc into docs/modules/<module>/pages/')
|
|
315
|
+
.requiredOption('-s, --subdir <subdir>', 'Relative path to the lab project subdirectory')
|
|
316
|
+
.requiredOption('-t, --target <filename>', 'Name of the target AsciiDoc file in pages/')
|
|
317
|
+
.action((options) => {
|
|
318
|
+
const repoRoot = findRepoRoot();
|
|
319
|
+
const normalized = options.subdir.replace(/\/+$/, '');
|
|
320
|
+
const moduleName = normalized.split('/')[0];
|
|
321
|
+
|
|
322
|
+
const projectDir = path.join(repoRoot, normalized);
|
|
323
|
+
const pagesDir = path.join(repoRoot, 'docs', 'modules', moduleName, 'pages');
|
|
324
|
+
const sourceFile = path.join(projectDir, 'README.adoc');
|
|
325
|
+
const destLink = path.join(pagesDir, options.target);
|
|
326
|
+
|
|
327
|
+
if (!fs.existsSync(projectDir)) {
|
|
328
|
+
console.error(`❌ Project directory not found: ${projectDir}`);
|
|
329
|
+
process.exit(1);
|
|
330
|
+
}
|
|
331
|
+
if (!fs.existsSync(sourceFile)) {
|
|
332
|
+
console.error(`❌ README.adoc not found in ${projectDir}`);
|
|
333
|
+
process.exit(1);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
fs.mkdirSync(pagesDir, { recursive: true });
|
|
337
|
+
const relPath = path.relative(pagesDir, sourceFile);
|
|
338
|
+
|
|
339
|
+
try {
|
|
340
|
+
fs.symlinkSync(relPath, destLink);
|
|
341
|
+
console.log(`✔️ Linked ${relPath} → ${destLink}`);
|
|
342
|
+
} catch (err) {
|
|
343
|
+
console.error(`❌ Failed to create symlink: ${err.message}`);
|
|
344
|
+
process.exit(1);
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
298
348
|
programCli
|
|
299
349
|
.command('fetch')
|
|
300
350
|
.description('Fetch a file or directory from GitHub and save locally')
|
|
@@ -182,7 +182,7 @@ function getDynamicReplacements(componentVersion, logger) {
|
|
|
182
182
|
const versionNum = formatVersion(componentVersion.version || '', semver);
|
|
183
183
|
const is24_3plus =
|
|
184
184
|
versionNum && semver.gte(versionNum, '24.3.0') && componentVersion.title === 'Self-Managed';
|
|
185
|
-
const useTagAttributes = isPrerelease || is24_3plus;
|
|
185
|
+
const useTagAttributes = isPrerelease || is24_3plus || componentVersion.title === 'Labs';
|
|
186
186
|
|
|
187
187
|
// Derive Redpanda / Console versions
|
|
188
188
|
const redpandaVersion = isPrerelease
|
package/macros/data-template.js
CHANGED
|
@@ -22,8 +22,8 @@ const jsonpath = require('jsonpath-plus');
|
|
|
22
22
|
const yaml = require('yaml');
|
|
23
23
|
// For synchronous HTTP fetching.
|
|
24
24
|
const request = require('sync-request');
|
|
25
|
-
const computeOut = require('../
|
|
26
|
-
const createAsciiDocFile = require('../
|
|
25
|
+
const computeOut = require('../extensions/util/compute-out.js');
|
|
26
|
+
const createAsciiDocFile = require('../extensions/util/create-asciidoc-file.js');
|
|
27
27
|
|
|
28
28
|
// In-memory cache for external resources (avoid repeated network calls)
|
|
29
29
|
const externalCache = new Map();
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|