Skip to content

Commit 8c5f812

Browse files
authored
Add support for excluding properties from docs (using Asciidoc tags) (#142)
* Add support for excluding properties from docs (using Asciidoc tags) * Set env var * Apply suggestion * Apply suggestions
1 parent 50dcc11 commit 8c5f812

17 files changed

+423
-808
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"properties": {
3+
"admin": {
4+
"description": "Network addresses for Admin API servers (excluded test)",
5+
"version": "v25.2.8",
6+
"exclude_from_docs": true
7+
},
8+
"cloud_storage_access_key": {
9+
"description": "Access key for cloud storage authentication (included test)",
10+
"version": "v25.2.8"
11+
}
12+
}
13+
}

bin/doc-tools.js

Lines changed: 92 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -502,11 +502,11 @@ function generatePropertyComparisonReport(oldTag, newTag, outputDir) {
502502
try {
503503
console.log(`\n📊 Generating detailed property comparison report...`);
504504

505-
// Look for the property JSON files in modules/reference/examples
506-
const repoRoot = findRepoRoot();
507-
const examplesDir = path.join(repoRoot, 'modules', 'reference', 'examples');
508-
const oldJsonPath = path.join(examplesDir, `${oldTag}-properties.json`);
509-
const newJsonPath = path.join(examplesDir, `${newTag}-properties.json`);
505+
// Look for the property JSON files in outputDir/examples
506+
const repoRoot = findRepoRoot();
507+
const examplesDir = path.join(repoRoot, outputDir, 'examples');
508+
const oldJsonPath = path.join(examplesDir, `${oldTag}-properties.json`);
509+
const newJsonPath = path.join(examplesDir, `${newTag}-properties.json`);
510510

511511
// Check if JSON files exist
512512
if (!fs.existsSync(oldJsonPath)) {
@@ -1031,28 +1031,31 @@ automation
10311031
});
10321032

10331033
automation
1034-
.command('property-docs')
1035-
.description('Generate JSON and AsciiDoc documentation for Redpanda configuration properties. By default, only extracts properties to JSON. Use --generate-partials to create consolidated AsciiDoc partials (including deprecated properties). Use --generate-pages to create complete property pages that include the partials using AsciiDoc includes.')
1034+
.command('property-docs')
1035+
.description(
1036+
'Generate JSON and consolidated AsciiDoc partials for Redpanda configuration properties. ' +
1037+
'By default, only extracts properties to JSON. Use --generate-partials to create consolidated ' +
1038+
'AsciiDoc partials (including deprecated properties).'
1039+
)
10361040
.option('--tag <tag>', 'Git tag or branch to extract from', 'dev')
10371041
.option('--diff <oldTag>', 'Also diff autogenerated properties from <oldTag> to <tag>')
10381042
.option('--overrides <path>', 'Optional JSON file with property description overrides')
10391043
.option('--output-dir <dir>', 'Where to write all generated files', 'modules/reference')
10401044
.option('--cloud-support', 'Add AsciiDoc tags to generated property docs to indicate which ones are supported in Redpanda Cloud. This data is fetched from the cloudv2 repository so requires a GitHub token with repo permissions. Set the token as an environment variable using GITHUB_TOKEN, GH_TOKEN, or REDPANDA_GITHUB_TOKEN')
1041-
.option('--template-property-page <path>', 'Custom Handlebars template for property page layout')
10421045
.option('--template-property <path>', 'Custom Handlebars template for individual property sections')
10431046
.option('--template-topic-property <path>', 'Custom Handlebars template for individual topic property sections')
1047+
.option('--template-topic-property-mappings <path>', 'Custom Handlebars template for topic property mappings table')
10441048
.option('--template-deprecated <path>', 'Custom Handlebars template for deprecated properties page')
10451049
.option('--template-deprecated-property <path>', 'Custom Handlebars template for individual deprecated property sections')
10461050
.option('--generate-partials', 'Generate consolidated property partials (cluster-properties.adoc, topic-properties.adoc, etc.) in the partials directory')
10471051
.option('--partials-dir <path>', 'Directory for property partials (relative to output-dir)', 'partials')
1048-
.option('--generate-pages', 'Generate complete property pages that include the partials using AsciiDoc includes')
1049-
.action((options) => {
1050-
verifyPropertyDependencies();
1052+
.action((options) => {
1053+
verifyPropertyDependencies();
10511054

10521055
// Validate cloud support dependencies if requested
10531056
if (options.cloudSupport) {
10541057
console.log('🔍 Validating cloud support dependencies...');
1055-
1058+
10561059
// Check for GITHUB_TOKEN, GH_TOKEN, or REDPANDA_GITHUB_TOKEN
10571060
const token = process.env.GITHUB_TOKEN || process.env.GH_TOKEN || process.env.REDPANDA_GITHUB_TOKEN;
10581061
if (!token) {
@@ -1065,7 +1068,7 @@ automation
10651068
console.error(' Or: export REDPANDA_GITHUB_TOKEN=your_token_here');
10661069
process.exit(1);
10671070
}
1068-
1071+
10691072
console.log('📦 Cloud support enabled - Python dependencies will be validated during execution');
10701073
if (process.env.VIRTUAL_ENV) {
10711074
console.log(` Using virtual environment: ${process.env.VIRTUAL_ENV}`);
@@ -1074,97 +1077,87 @@ automation
10741077
console.log('✅ GitHub token validated');
10751078
}
10761079

1077-
const newTag = options.tag;
1078-
const oldTag = options.diff;
1079-
const overridesPath = options.overrides;
1080-
const outputDir = options.outputDir;
1081-
const cwd = path.resolve(__dirname, '../tools/property-extractor');
1082-
1083-
const make = (tag, overrides, templates = {}, outputDir = 'modules/reference/', tempDir = null, cloudSupport = false) => {
1084-
console.log(`⏳ Building property docs for ${tag}${tempDir ? ' (for diff)' : ''}…`);
1085-
const args = ['build', `TAG=${tag}`];
1086-
1087-
// Pass all paths as environment variables for consistency
1088-
const env = { ...process.env };
1089-
if (overrides) {
1090-
env.OVERRIDES = path.resolve(overrides);
1091-
}
1092-
if (cloudSupport) {
1093-
env.CLOUD_SUPPORT = '1';
1094-
}
1095-
if (templates.propertyPage) {
1096-
env.TEMPLATE_PROPERTY_PAGE = path.resolve(templates.propertyPage);
1097-
env.TEMPLATE_PROPERTY_PAGE_WITH_INCLUDES = env.TEMPLATE_PROPERTY_PAGE;
1098-
}
1099-
if (templates.property) {
1100-
env.TEMPLATE_PROPERTY = path.resolve(templates.property);
1101-
}
1102-
if (templates.topicProperty) {
1103-
env.TEMPLATE_TOPIC_PROPERTY = path.resolve(templates.topicProperty);
1104-
}
1105-
if (templates.deprecated) {
1106-
env.TEMPLATE_DEPRECATED = path.resolve(templates.deprecated);
1107-
}
1108-
if (templates.deprecatedProperty) {
1109-
env.TEMPLATE_DEPRECATED_PROPERTY = path.resolve(templates.deprecatedProperty);
1110-
}
1111-
1112-
if (tempDir) {
1113-
env.OUTPUT_JSON_DIR = path.resolve(tempDir, 'examples');
1114-
env.OUTPUT_AUTOGENERATED_DIR = path.resolve(tempDir);
1115-
} else {
1116-
env.OUTPUT_JSON_DIR = path.resolve(outputDir, 'examples');
1117-
env.OUTPUT_AUTOGENERATED_DIR = path.resolve(outputDir);
1118-
// Set property files to go to properties subdirectory
1119-
env.OUTPUT_ASCIIDOC_DIR = path.resolve(outputDir, 'pages', 'properties');
1120-
}
1121-
1122-
// Set partials generation options
1123-
if (options.generatePartials) {
1124-
env.GENERATE_PARTIALS = '1';
1125-
env.OUTPUT_PARTIALS_DIR = path.resolve(outputDir, options.partialsDir || 'partials');
1126-
}
1127-
1128-
// Set page generation options
1129-
if (options.generatePages) {
1130-
env.GENERATE_PAGES = '1';
1131-
if (templates.propertyPage) {
1132-
env.TEMPLATE_PROPERTY_PAGE_WITH_INCLUDES = env.TEMPLATE_PROPERTY_PAGE;
1080+
const newTag = options.tag;
1081+
const oldTag = options.diff;
1082+
const overridesPath = options.overrides;
1083+
const outputDir = options.outputDir;
1084+
const cwd = path.resolve(__dirname, '../tools/property-extractor');
1085+
1086+
const make = (tag, overrides, templates = {}, outDir = 'modules/reference/', tempDir = null) => {
1087+
console.log(`⏳ Building property docs for ${tag}${tempDir ? ' (for diff)' : ''}…`);
1088+
const args = ['build', `TAG=${tag}`];
1089+
1090+
// Pass all paths as environment variables for consistency
1091+
const env = { ...process.env };
1092+
1093+
if (overrides) {
1094+
env.OVERRIDES = path.resolve(overrides);
1095+
}
1096+
if (options.cloudSupport) {
1097+
env.CLOUD_SUPPORT = '1';
1098+
}
1099+
if (templates.property) {
1100+
env.TEMPLATE_PROPERTY = path.resolve(templates.property);
1101+
}
1102+
if (templates.topicProperty) {
1103+
env.TEMPLATE_TOPIC_PROPERTY = path.resolve(templates.topicProperty);
1104+
}
1105+
if (templates.topicPropertyMappings) {
1106+
env.TEMPLATE_TOPIC_PROPERTY_MAPPINGS = path.resolve(templates.topicPropertyMappings);
1107+
}
1108+
if (templates.deprecated) {
1109+
env.TEMPLATE_DEPRECATED = path.resolve(templates.deprecated);
1110+
}
1111+
if (templates.deprecatedProperty) {
1112+
env.TEMPLATE_DEPRECATED_PROPERTY = path.resolve(templates.deprecatedProperty);
1113+
}
1114+
1115+
if (tempDir) {
1116+
env.OUTPUT_JSON_DIR = path.resolve(tempDir, 'examples');
1117+
env.OUTPUT_AUTOGENERATED_DIR = path.resolve(tempDir);
1118+
} else {
1119+
env.OUTPUT_JSON_DIR = path.resolve(outDir, 'examples');
1120+
env.OUTPUT_AUTOGENERATED_DIR = path.resolve(outDir);
11331121
}
1134-
}
1135-
1136-
const r = spawnSync('make', args, { cwd, stdio: 'inherit', env });
1137-
if (r.error) {
1138-
console.error(`❌ ${r.error.message}`);
1139-
process.exit(1);
1140-
}
1141-
if (r.status !== 0) process.exit(r.status);
1142-
};
11431122

1144-
// Collect template options
1145-
const templates = {
1146-
propertyPage: options.templatePropertyPage,
1147-
property: options.templateProperty,
1148-
topicProperty: options.templateTopicProperty,
1149-
deprecated: options.templateDeprecated,
1150-
deprecatedProperty: options.templateDeprecatedProperty
1151-
};
1123+
// Partials generation options
1124+
if (options.generatePartials) {
1125+
env.GENERATE_PARTIALS = '1';
1126+
env.OUTPUT_PARTIALS_DIR = path.resolve(outDir, options.partialsDir || 'partials');
1127+
}
11521128

1153-
if (oldTag) {
1154-
// Generate old version directly to final destination so its JSON is available for comparison
1155-
make(oldTag, overridesPath, templates, outputDir, null, options.cloudSupport);
1156-
}
1129+
const r = spawnSync('make', args, { cwd, stdio: 'inherit', env });
1130+
if (r.error) {
1131+
console.error(`❌ ${r.error.message}`);
1132+
process.exit(1);
1133+
}
1134+
if (r.status !== 0) process.exit(r.status);
1135+
};
1136+
1137+
// Collect template options
1138+
const templates = {
1139+
property: options.templateProperty,
1140+
topicProperty: options.templateTopicProperty,
1141+
topicPropertyMappings: options.templateTopicPropertyMappings,
1142+
deprecated: options.templateDeprecated,
1143+
deprecatedProperty: options.templateDeprecatedProperty,
1144+
};
1145+
1146+
if (oldTag) {
1147+
// Build old version first so its JSON exists for the diff step
1148+
make(oldTag, overridesPath, templates, outputDir, null);
1149+
}
11571150

1158-
// Generate new version to final destination
1159-
make(newTag, overridesPath, templates, outputDir, null, options.cloudSupport);
1151+
// Build new version
1152+
make(newTag, overridesPath, templates, outputDir, null);
11601153

1161-
if (oldTag) {
1162-
// Generate property comparison report using the JSON files now in modules/reference/examples
1163-
generatePropertyComparisonReport(oldTag, newTag, 'modules/reference');
1164-
}
1154+
if (oldTag) {
1155+
// Generate property comparison report using the JSON now in outputDir/examples
1156+
generatePropertyComparisonReport(oldTag, newTag, outputDir);
1157+
}
11651158

1166-
process.exit(0);
1167-
});
1159+
process.exit(0);
1160+
});
11681161

11691162
automation
11701163
.command('rpk-docs')
@@ -1563,7 +1556,7 @@ automation
15631556
automation
15641557
.command('bundle-openapi')
15651558
.description('Bundle Redpanda OpenAPI fragments for admin and connect APIs into complete OpenAPI 3.1 documents')
1566-
.requiredOption('-t, --tag <tag>', 'Git tag to check out (e.g., v24.3.2 or 24.3.2 or dev)')
1559+
.requiredOption('-t, --tag <tag>', 'Branch or tag to clone from the repository (for example v24.3.2 or 24.3.2 or dev)')
15671560
.option('--repo <url>', 'Repository URL', 'https://github.com/redpanda-data/redpanda.git')
15681561
.addOption(new Option('-s, --surface <surface>', 'Which API surface(s) to bundle').choices(['admin', 'connect', 'both']).makeOptionMandatory())
15691562
.option('--out-admin <path>', 'Output path for admin API', 'admin/redpanda-admin-api.yaml')

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.10.3",
3+
"version": "4.10.4",
44
"description": "Antora extensions and macros developed for Redpanda documentation.",
55
"keywords": [
66
"antora",

tools/property-extractor/compare-properties.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ function compareProperties(oldData, newData, oldVersion, newVersion) {
148148
name,
149149
type: prop.type,
150150
default: prop.default,
151-
description: prop.description ? prop.description.substring(0, 100) + '...' : 'No description'
151+
description: prop.description || 'No description'
152152
});
153153
}
154154
}
@@ -185,8 +185,8 @@ function compareProperties(oldData, newData, oldVersion, newVersion) {
185185
if (oldProp.description !== newProp.description) {
186186
report.changedDescriptions.push({
187187
name,
188-
oldDescription: oldProp.description ? oldProp.description.substring(0, 50) + '...' : 'No description',
189-
newDescription: newProp.description ? newProp.description.substring(0, 50) + '...' : 'No description'
188+
oldDescription: oldProp.description || 'No description',
189+
newDescription: newProp.description || 'No description'
190190
});
191191
}
192192

@@ -203,7 +203,7 @@ function compareProperties(oldData, newData, oldVersion, newVersion) {
203203
report.removedProperties.push({
204204
name,
205205
type: oldProp.type,
206-
description: oldProp.description ? oldProp.description.substring(0, 100) + '...' : 'No description'
206+
description: oldProp.description || 'No description'
207207
});
208208
}
209209
}

0 commit comments

Comments
 (0)