Skip to content

Commit 1ee3652

Browse files
doc-tools link-readme CLI command (#101)
* Add a doc-tools CLI command so that writers and our tests have access to a consistent set of tools * Bump version * Add submodule * Add tree-sitter-cpp submodule * Add tree-sitter-c grammar as dependency of C++ parser * Add tree-sitter-c grammar as required by tree-sitter-cpp * Add property automation to CLI * Add CLI help * doc-tools CLI * Remove tree‑sitter‑cpp submodule; clone on demand instead * Fix paths * Fix makefile * Update package.json * Update package-lock.json * Fix packages * Cleanup * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Refactor * Add Iceberg support in test cluster * Fix error * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Final fixes * Apply suggestions * Add support for the new gets_restored metadata introduced in redpanda-data/redpanda#25105 * Add fetch command for saving files from other repos locally * Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Add support for a --diff flag * Use tags for Redpanda labs * Add symlink util for labs to the CLI * Remove utils --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent b50adcd commit 1ee3652

File tree

7 files changed

+55
-7
lines changed

7 files changed

+55
-7
lines changed

bin/doc-tools.js

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ const { Command } = require('commander');
55
const path = require('path');
66
const fs = require('fs');
77

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+
822
// --------------------------------------------------------------------
923
// Dependency check functions
1024
// --------------------------------------------------------------------
@@ -107,7 +121,7 @@ const programCli = new Command();
107121
programCli
108122
.name('doc-tools')
109123
.description('Redpanda Document Automation CLI')
110-
.version('1.0.0');
124+
.version('1.0.1');
111125

112126
// Top-level commands.
113127
programCli
@@ -295,6 +309,40 @@ automation
295309
process.exit(0);
296310
});
297311

312+
programCli
313+
.command('link-readme <subdir> <targetFilename>')
314+
.description('Symlink a README.adoc into docs/modules/<module>/pages/')
315+
.action((subdir, targetFilename) => {
316+
const repoRoot = findRepoRoot();
317+
const normalized = subdir.replace(/\/+$/, '');
318+
const moduleName = normalized.split('/')[0];
319+
320+
const projectDir = path.join(repoRoot, normalized);
321+
const pagesDir = path.join(repoRoot, 'docs', 'modules', moduleName, 'pages');
322+
const sourceFile = path.join(repoRoot, normalized, 'README.adoc');
323+
const destLink = path.join(pagesDir, targetFilename);
324+
325+
if (!fs.existsSync(projectDir)) {
326+
console.error(`❌ Project directory not found: ${projectDir}`);
327+
process.exit(1);
328+
}
329+
if (!fs.existsSync(sourceFile)) {
330+
console.error(`❌ README.adoc not found in ${normalized}`);
331+
process.exit(1);
332+
}
333+
334+
fs.mkdirSync(pagesDir, { recursive: true });
335+
const relPath = path.relative(pagesDir, sourceFile);
336+
337+
try {
338+
fs.symlinkSync(relPath, destLink);
339+
console.log(`✔️ Linked ${relPath}${destLink}`);
340+
} catch (err) {
341+
console.error(`❌ Failed to create symlink: ${err.message}`);
342+
process.exit(1);
343+
}
344+
});
345+
298346
programCli
299347
.command('fetch')
300348
.description('Fetch a file or directory from GitHub and save locally')

extensions/replace-attributes-in-attachments.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ function getDynamicReplacements(componentVersion, logger) {
182182
const versionNum = formatVersion(componentVersion.version || '', semver);
183183
const is24_3plus =
184184
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';
186186

187187
// Derive Redpanda / Console versions
188188
const redpandaVersion = isPrerelease
File renamed without changes.

macros/data-template.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ const jsonpath = require('jsonpath-plus');
2222
const yaml = require('yaml');
2323
// For synchronous HTTP fetching.
2424
const request = require('sync-request');
25-
const computeOut = require('../extension-utils/compute-out.js');
26-
const createAsciiDocFile = require('../extension-utils/create-asciidoc-file.js');
25+
const computeOut = require('../extensions/util/compute-out.js');
26+
const createAsciiDocFile = require('../extensions/util/create-asciidoc-file.js');
2727

2828
// In-memory cache for external resources (avoid repeated network calls)
2929
const externalCache = new Map();

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@redpanda-data/docs-extensions-and-macros",
3-
"version": "4.4.0",
3+
"version": "4.4.1",
44
"description": "Antora extensions and macros developed for Redpanda documentation.",
55
"keywords": [
66
"antora",

0 commit comments

Comments
 (0)