@redpanda-data/docs-extensions-and-macros 4.7.4 → 4.8.1
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 +90 -20
- package/package.json +1 -1
- package/tools/property-extractor/Makefile +64 -24
- package/tools/property-extractor/generate-handlebars-docs.js +344 -0
- package/tools/property-extractor/helpers/and.js +10 -0
- package/tools/property-extractor/helpers/eq.js +9 -0
- package/tools/property-extractor/helpers/formatPropertyValue.js +128 -0
- package/tools/property-extractor/helpers/formatUnits.js +26 -0
- package/tools/property-extractor/helpers/index.js +13 -0
- package/tools/property-extractor/helpers/join.js +18 -0
- package/tools/property-extractor/helpers/ne.js +9 -0
- package/tools/property-extractor/helpers/not.js +8 -0
- package/tools/property-extractor/helpers/or.js +10 -0
- package/tools/property-extractor/helpers/renderPropertyExample.js +42 -0
- package/tools/property-extractor/package-lock.json +77 -0
- package/tools/property-extractor/package.json +6 -0
- package/tools/property-extractor/property_extractor.py +1163 -20
- package/tools/property-extractor/requirements.txt +1 -0
- package/tools/property-extractor/templates/deprecated-properties.hbs +25 -0
- package/tools/property-extractor/templates/deprecated-property.hbs +7 -0
- package/tools/property-extractor/templates/property-page.hbs +22 -0
- package/tools/property-extractor/templates/property.hbs +70 -0
- package/tools/property-extractor/templates/topic-property.hbs +59 -0
- package/tools/property-extractor/topic_property_extractor.py +630 -0
- package/tools/property-extractor/transformers.py +80 -4
- package/tools/property-extractor/json-to-asciidoc/generate_docs.py +0 -466
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const handlebars = require('handlebars');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Helper function to format a value (used in object/array formatting)
|
|
5
|
+
*/
|
|
6
|
+
function formatValue(val) {
|
|
7
|
+
if (typeof val === 'string') {
|
|
8
|
+
return `"${val}"`;
|
|
9
|
+
} else if (typeof val === 'boolean') {
|
|
10
|
+
return val ? 'true' : 'false';
|
|
11
|
+
} else if (val === null || val === undefined) {
|
|
12
|
+
return 'null';
|
|
13
|
+
} else if (Array.isArray(val)) {
|
|
14
|
+
return "[" + val.map(v => formatValue(v)).join(", ") + "]";
|
|
15
|
+
} else if (typeof val === 'object' && val !== null) {
|
|
16
|
+
return JSON.stringify(val);
|
|
17
|
+
} else {
|
|
18
|
+
return String(val);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Process C++ internal representations and convert them to user-friendly formats
|
|
24
|
+
* This matches the Python process_defaults function logic
|
|
25
|
+
*/
|
|
26
|
+
function processDefaults(inputString, suffix) {
|
|
27
|
+
if (typeof inputString !== 'string') {
|
|
28
|
+
return inputString;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Test for ip:port in vector: std::vector<net::unresolved_address>({{...}})
|
|
32
|
+
const vectorMatch = inputString.match(/std::vector<net::unresolved_address>\(\{\{("([\d.]+)",\s*(\d+))\}\}\)/);
|
|
33
|
+
if (vectorMatch) {
|
|
34
|
+
const ip = vectorMatch[2];
|
|
35
|
+
const port = vectorMatch[3];
|
|
36
|
+
return [`${ip}:${port}`];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// Test for ip:port in single-string: net::unresolved_address("127.0.0.1", 9092)
|
|
40
|
+
const brokerMatch = inputString.match(/net::unresolved_address\("([\d.]+)",\s*(\d+)\)/);
|
|
41
|
+
if (brokerMatch) {
|
|
42
|
+
const ip = brokerMatch[1];
|
|
43
|
+
const port = brokerMatch[2];
|
|
44
|
+
return `${ip}:${port}`;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Handle std::nullopt
|
|
48
|
+
if (inputString.includes('std::nullopt')) {
|
|
49
|
+
return inputString.replace(/std::nullopt/g, 'null');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Handle time units and other patterns would go here...
|
|
53
|
+
// For now, return the original string
|
|
54
|
+
return inputString;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Formats a property value for display, matching Python legacy format exactly
|
|
59
|
+
* @param {*} value - The value to format
|
|
60
|
+
* @param {string} type - The property type
|
|
61
|
+
* @returns {handlebars.SafeString} Formatted value
|
|
62
|
+
*/
|
|
63
|
+
module.exports = function formatPropertyValue(value, type) {
|
|
64
|
+
if (value === null || value === undefined || value === '') {
|
|
65
|
+
return new handlebars.SafeString('null');
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (typeof value === 'boolean') {
|
|
69
|
+
return new handlebars.SafeString(value ? 'true' : 'false');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (typeof value === 'object' && !Array.isArray(value)) {
|
|
73
|
+
// Format object defaults with Python-style syntax: {key: "value", key2: value2}
|
|
74
|
+
const pairs = [];
|
|
75
|
+
for (const [k, v] of Object.entries(value)) {
|
|
76
|
+
// Process each value for C++ representations
|
|
77
|
+
let processedValue = v;
|
|
78
|
+
if (typeof v === 'string') {
|
|
79
|
+
processedValue = processDefaults(v, null);
|
|
80
|
+
}
|
|
81
|
+
pairs.push(`${k}: ${formatValue(processedValue)}`);
|
|
82
|
+
}
|
|
83
|
+
return new handlebars.SafeString(`{${pairs.join(', ')}}`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
if (Array.isArray(value)) {
|
|
87
|
+
// Handle array defaults to match Python format
|
|
88
|
+
if (value.length === 0) {
|
|
89
|
+
return new handlebars.SafeString('[]');
|
|
90
|
+
} else {
|
|
91
|
+
// Format each array element
|
|
92
|
+
const formattedElements = [];
|
|
93
|
+
for (const item of value) {
|
|
94
|
+
if (typeof item === 'object' && item !== null) {
|
|
95
|
+
// Format object within array
|
|
96
|
+
const pairs = [];
|
|
97
|
+
for (const [k, v] of Object.entries(item)) {
|
|
98
|
+
// Process each value for C++ representations
|
|
99
|
+
let processedValue = v;
|
|
100
|
+
if (typeof v === 'string') {
|
|
101
|
+
processedValue = processDefaults(v, null);
|
|
102
|
+
}
|
|
103
|
+
pairs.push(`${k}: ${formatValue(processedValue)}`);
|
|
104
|
+
}
|
|
105
|
+
formattedElements.push(`{${pairs.join(', ')}}`);
|
|
106
|
+
} else {
|
|
107
|
+
formattedElements.push(String(item));
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return new handlebars.SafeString(`[${formattedElements.join(', ')}]`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// For other types, handle strings vs non-strings differently
|
|
115
|
+
let result;
|
|
116
|
+
if (typeof value === 'string') {
|
|
117
|
+
// Keep strings as-is (preserve original characters and casing)
|
|
118
|
+
result = value;
|
|
119
|
+
} else {
|
|
120
|
+
// Convert non-string values to String without altering case/quotes
|
|
121
|
+
result = String(value);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
// Apply C++ processing
|
|
125
|
+
result = processDefaults(result, null);
|
|
126
|
+
|
|
127
|
+
return new handlebars.SafeString(result);
|
|
128
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats units for display based on property name suffix
|
|
3
|
+
* @param {string} name - Property name that might contain unit suffixes
|
|
4
|
+
* @returns {string} Formatted unit description
|
|
5
|
+
*/
|
|
6
|
+
module.exports = function formatUnits(name) {
|
|
7
|
+
const suffixToUnit = {
|
|
8
|
+
'ms': 'milliseconds',
|
|
9
|
+
'sec': 'seconds',
|
|
10
|
+
'seconds': 'seconds',
|
|
11
|
+
'bytes': 'bytes',
|
|
12
|
+
'buf': 'bytes',
|
|
13
|
+
'partitions': 'number of partitions per topic',
|
|
14
|
+
'percent': 'percent',
|
|
15
|
+
'bps': 'bytes per second',
|
|
16
|
+
'fraction': 'fraction'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
if (!name) return '';
|
|
20
|
+
|
|
21
|
+
// Extract the last part after splitting on underscores (like Python implementation)
|
|
22
|
+
const parts = name.split('_');
|
|
23
|
+
const suffix = parts[parts.length - 1];
|
|
24
|
+
|
|
25
|
+
return suffixToUnit[suffix] || '';
|
|
26
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
module.exports = {
|
|
4
|
+
join: require('./join.js'),
|
|
5
|
+
eq: require('./eq.js'),
|
|
6
|
+
ne: require('./ne.js'),
|
|
7
|
+
and: require('./and.js'),
|
|
8
|
+
or: require('./or.js'),
|
|
9
|
+
not: require('./not.js'),
|
|
10
|
+
formatPropertyValue: require('./formatPropertyValue.js'),
|
|
11
|
+
renderPropertyExample: require('./renderPropertyExample.js'),
|
|
12
|
+
formatUnits: require('./formatUnits.js'),
|
|
13
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handlebars helper to join an array with a separator
|
|
3
|
+
* @param {Array} array - The array to join
|
|
4
|
+
* @param {string} separator - The separator to use
|
|
5
|
+
* @returns {string} The joined string
|
|
6
|
+
*/
|
|
7
|
+
module.exports = function join(array, separator) {
|
|
8
|
+
if (!Array.isArray(array)) {
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Detect and ignore Handlebars options object
|
|
13
|
+
if (separator && typeof separator === 'object' && (separator.hash !== undefined || separator.data !== undefined)) {
|
|
14
|
+
separator = undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return array.join(separator || ', ');
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Handlebars helper for logical OR
|
|
3
|
+
* @param {...*} args - Values to check
|
|
4
|
+
* @returns {boolean} True if any value is truthy
|
|
5
|
+
*/
|
|
6
|
+
module.exports = function or(...args) {
|
|
7
|
+
// Remove the last argument which is the Handlebars options object
|
|
8
|
+
const values = args.slice(0, -1);
|
|
9
|
+
return values.some(val => !!val);
|
|
10
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
const handlebars = require('handlebars');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Renders an example for a property based on its format
|
|
5
|
+
* @param {Object} property - The property object containing example data
|
|
6
|
+
* @returns {handlebars.SafeString} Formatted example block
|
|
7
|
+
*/
|
|
8
|
+
module.exports = function renderPropertyExample(property) {
|
|
9
|
+
if (!property.example) {
|
|
10
|
+
return new handlebars.SafeString('');
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
let exampleContent = '';
|
|
14
|
+
|
|
15
|
+
// Handle different example formats
|
|
16
|
+
if (typeof property.example === 'string') {
|
|
17
|
+
// Check if it's already a complete AsciiDoc example
|
|
18
|
+
if (property.example.includes('.Example') || property.example.includes('[,yaml]')) {
|
|
19
|
+
exampleContent = property.example;
|
|
20
|
+
} else {
|
|
21
|
+
// Simple string example - wrap it
|
|
22
|
+
exampleContent = `.Example\n[,yaml]\n----\n${property.name}: ${property.example}\n----`;
|
|
23
|
+
}
|
|
24
|
+
} else if (Array.isArray(property.example)) {
|
|
25
|
+
// Multiline array example
|
|
26
|
+
exampleContent = property.example.join('\n');
|
|
27
|
+
} else if (typeof property.example === 'object' && property.example.title) {
|
|
28
|
+
// Structured example with title and content
|
|
29
|
+
exampleContent = `.${property.example.title}\n`;
|
|
30
|
+
if (property.example.description) {
|
|
31
|
+
exampleContent += `${property.example.description}\n\n`;
|
|
32
|
+
}
|
|
33
|
+
if (property.example.config) {
|
|
34
|
+
exampleContent += `[,yaml]\n----\n${JSON.stringify(property.example.config, null, 2)}\n----`;
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
// Fallback: JSON stringify the example
|
|
38
|
+
exampleContent = `.Example\n[,yaml]\n----\n${property.name}: ${JSON.stringify(property.example, null, 2)}\n----`;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return new handlebars.SafeString('\n' + exampleContent + '\n');
|
|
42
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "property-extractor",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"lockfileVersion": 3,
|
|
5
|
+
"requires": true,
|
|
6
|
+
"packages": {
|
|
7
|
+
"": {
|
|
8
|
+
"dependencies": {
|
|
9
|
+
"handlebars": "^4.7.8"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"node_modules/handlebars": {
|
|
13
|
+
"version": "4.7.8",
|
|
14
|
+
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.8.tgz",
|
|
15
|
+
"integrity": "sha512-vafaFqs8MZkRrSX7sFVUdo3ap/eNiLnb4IakshzvP56X5Nr1iGKAIqdX6tMlm6HcNRIkr6AxO5jFEoJzzpT8aQ==",
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"minimist": "^1.2.5",
|
|
19
|
+
"neo-async": "^2.6.2",
|
|
20
|
+
"source-map": "^0.6.1",
|
|
21
|
+
"wordwrap": "^1.0.0"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"handlebars": "bin/handlebars"
|
|
25
|
+
},
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=0.4.7"
|
|
28
|
+
},
|
|
29
|
+
"optionalDependencies": {
|
|
30
|
+
"uglify-js": "^3.1.4"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"node_modules/minimist": {
|
|
34
|
+
"version": "1.2.8",
|
|
35
|
+
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
|
|
36
|
+
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"funding": {
|
|
39
|
+
"url": "https://github.com/sponsors/ljharb"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
"node_modules/neo-async": {
|
|
43
|
+
"version": "2.6.2",
|
|
44
|
+
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz",
|
|
45
|
+
"integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==",
|
|
46
|
+
"license": "MIT"
|
|
47
|
+
},
|
|
48
|
+
"node_modules/source-map": {
|
|
49
|
+
"version": "0.6.1",
|
|
50
|
+
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
|
51
|
+
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
|
52
|
+
"license": "BSD-3-Clause",
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=0.10.0"
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"node_modules/uglify-js": {
|
|
58
|
+
"version": "3.19.3",
|
|
59
|
+
"resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.19.3.tgz",
|
|
60
|
+
"integrity": "sha512-v3Xu+yuwBXisp6QYTcH4UbH+xYJXqnq2m/LtQVWKWzYc1iehYnLixoQDN9FH6/j9/oybfd6W9Ghwkl8+UMKTKQ==",
|
|
61
|
+
"license": "BSD-2-Clause",
|
|
62
|
+
"optional": true,
|
|
63
|
+
"bin": {
|
|
64
|
+
"uglifyjs": "bin/uglifyjs"
|
|
65
|
+
},
|
|
66
|
+
"engines": {
|
|
67
|
+
"node": ">=0.8.0"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"node_modules/wordwrap": {
|
|
71
|
+
"version": "1.0.0",
|
|
72
|
+
"resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz",
|
|
73
|
+
"integrity": "sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==",
|
|
74
|
+
"license": "MIT"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|