@redpanda-data/docs-extensions-and-macros 4.12.1 → 4.12.3
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 +354 -89
- package/extensions/algolia-indexer/generate-index.js +43 -27
- package/package.json +1 -1
- package/tools/property-extractor/Makefile +63 -8
- package/tools/property-extractor/README.adoc +973 -621
- package/tools/property-extractor/compare-properties.js +10 -6
- package/tools/property-extractor/generate-handlebars-docs.js +9 -6
- package/tools/property-extractor/property_extractor.py +93 -10
- package/tools/property-extractor/templates/topic-property-mappings.hbs +6 -1
- package/tools/property-extractor/templates/topic-property.hbs +1 -1
- package/tools/property-extractor/topic_property_extractor.py +269 -65
- package/tools/redpanda-connect/README.adoc +736 -0
- package/tools/redpanda-connect/helpers/renderConnectFields.js +73 -29
- package/tools/redpanda-connect/helpers/renderLeafField.js +10 -3
- package/tools/redpanda-connect/helpers/renderYamlList.js +7 -2
- package/tools/redpanda-connect/helpers/toYaml.js +8 -3
- package/tools/redpanda-connect/report-delta.js +64 -2
|
@@ -0,0 +1,736 @@
|
|
|
1
|
+
= Redpanda Connect Documentation Automation
|
|
2
|
+
|
|
3
|
+
Automatically generates Redpanda Connect connector documentation and manages version updates.
|
|
4
|
+
|
|
5
|
+
== What is this?
|
|
6
|
+
|
|
7
|
+
The Redpanda Connect automation is part of the https://github.com/redpanda-data/docs-extensions-and-macros[`docs-extensions-and-macros`] package. It automates the generation and maintenance of Redpanda Connect component documentation by:
|
|
8
|
+
|
|
9
|
+
* Fetching connector metadata from the Redpanda Connect repository
|
|
10
|
+
* Generating AsciiDoc documentation for inputs, outputs, processors, caches, and other components
|
|
11
|
+
* Managing version tracking and change detection
|
|
12
|
+
* Creating connector catalogs and category pages
|
|
13
|
+
|
|
14
|
+
**Why it exists:** Redpanda Connect has hundreds of connectors and components with complex configurations. Manually maintaining documentation for all these components would be time-consuming and error-prone. This automation extracts component schemas from the Redpanda Connect repository and generates accurate, up-to-date documentation.
|
|
15
|
+
|
|
16
|
+
**What it generates:**
|
|
17
|
+
|
|
18
|
+
* *Component reference documentation* (AsciiDoc files for each connector)
|
|
19
|
+
* *Connector catalog* with support levels and availability
|
|
20
|
+
* *Version tracking* and change reports
|
|
21
|
+
* *Category pages* organizing components by type
|
|
22
|
+
|
|
23
|
+
== For documentation writers
|
|
24
|
+
|
|
25
|
+
=== Quick start
|
|
26
|
+
|
|
27
|
+
The Redpanda Connect automation is installed as part of the `docs-extensions-and-macros` npm package. You interact with it through the `doc-tools` CLI from within your documentation repository.
|
|
28
|
+
|
|
29
|
+
*Prerequisites:*
|
|
30
|
+
|
|
31
|
+
* Node.js 18+ and npm
|
|
32
|
+
* Git
|
|
33
|
+
|
|
34
|
+
*Installation:*
|
|
35
|
+
|
|
36
|
+
[,bash]
|
|
37
|
+
----
|
|
38
|
+
# In your docs repository
|
|
39
|
+
npm install @redpanda-data/docs-extensions-and-macros
|
|
40
|
+
----
|
|
41
|
+
|
|
42
|
+
*Generate connector documentation:*
|
|
43
|
+
|
|
44
|
+
[,bash]
|
|
45
|
+
----
|
|
46
|
+
# Generate connector documentation with latest data
|
|
47
|
+
npx doc-tools generate rpcn-connector-docs --fetch-connectors
|
|
48
|
+
|
|
49
|
+
# Generate with custom overrides
|
|
50
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
51
|
+
--fetch-connectors \
|
|
52
|
+
--overrides path/to/overrides.json
|
|
53
|
+
|
|
54
|
+
# Generate and draft missing connectors
|
|
55
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
56
|
+
--fetch-connectors \
|
|
57
|
+
--draft-missing
|
|
58
|
+
|
|
59
|
+
# Use existing data file without fetching
|
|
60
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
61
|
+
--data-dir docs-data
|
|
62
|
+
----
|
|
63
|
+
|
|
64
|
+
=== Version matching behavior
|
|
65
|
+
|
|
66
|
+
**IMPORTANT:** When the fetched Redpanda Connect version matches the version already specified in `antora.yml`, the automation automatically skips:
|
|
67
|
+
|
|
68
|
+
* Diff generation (no changes to compare)
|
|
69
|
+
* "What's New" updates (no new features to document)
|
|
70
|
+
* Version attribute updates (already at that version)
|
|
71
|
+
|
|
72
|
+
This prevents unnecessary churn when re-running the automation on the same version.
|
|
73
|
+
|
|
74
|
+
[,yaml]
|
|
75
|
+
----
|
|
76
|
+
# antora.yml
|
|
77
|
+
name: redpanda-connect
|
|
78
|
+
asciidoc:
|
|
79
|
+
attributes:
|
|
80
|
+
latest-connect-version: 4.53.0 # Current documented version
|
|
81
|
+
----
|
|
82
|
+
|
|
83
|
+
[,bash]
|
|
84
|
+
----
|
|
85
|
+
# If you run automation and rpk reports 4.53.0, antora.yml already has 4.53.0:
|
|
86
|
+
npx doc-tools generate rpcn-connector-docs --fetch-connectors
|
|
87
|
+
|
|
88
|
+
# Output:
|
|
89
|
+
# ✓ Already at version 4.53.0
|
|
90
|
+
# No diff or version updates needed.
|
|
91
|
+
# (Still generates partials but skips diff/updates)
|
|
92
|
+
|
|
93
|
+
# If you run automation and rpk reports 4.54.0, antora.yml has 4.53.0:
|
|
94
|
+
npx doc-tools generate rpcn-connector-docs --fetch-connectors
|
|
95
|
+
|
|
96
|
+
# Output:
|
|
97
|
+
# ✅ Connector diff JSON written to: docs-data/connect-diff-4.53.0_to_4.54.0.json
|
|
98
|
+
# ✅ Updated Antora version: 4.54.0
|
|
99
|
+
# (Generates diff, updates version, creates "what's new" data)
|
|
100
|
+
----
|
|
101
|
+
|
|
102
|
+
=== Generated output
|
|
103
|
+
|
|
104
|
+
Running Connect automation creates:
|
|
105
|
+
|
|
106
|
+
[,text]
|
|
107
|
+
----
|
|
108
|
+
modules/components/
|
|
109
|
+
├── partials/
|
|
110
|
+
│ ├── fields/
|
|
111
|
+
│ │ ├── inputs/
|
|
112
|
+
│ │ │ ├── kafka_franz.adoc
|
|
113
|
+
│ │ │ ├── http_server.adoc
|
|
114
|
+
│ │ │ └── ...
|
|
115
|
+
│ │ ├── outputs/
|
|
116
|
+
│ │ │ ├── elasticsearch_v8.adoc
|
|
117
|
+
│ │ │ ├── kafka_franz.adoc
|
|
118
|
+
│ │ │ └── ...
|
|
119
|
+
│ │ ├── processors/
|
|
120
|
+
│ │ ├── caches/
|
|
121
|
+
│ │ └── ...
|
|
122
|
+
│ ├── examples/
|
|
123
|
+
│ │ ├── inputs/
|
|
124
|
+
│ │ ├── outputs/
|
|
125
|
+
│ │ └── ...
|
|
126
|
+
│ └── drafts/ # Full draft pages (if --writeFullDrafts)
|
|
127
|
+
├── examples/
|
|
128
|
+
│ ├── common/ # Common configuration examples
|
|
129
|
+
│ └── advanced/ # Advanced configuration examples
|
|
130
|
+
└── pages/
|
|
131
|
+
├── connect-api-reference.adoc
|
|
132
|
+
└── ...
|
|
133
|
+
----
|
|
134
|
+
|
|
135
|
+
=== Common workflows
|
|
136
|
+
|
|
137
|
+
==== Updating to a new Redpanda Connect version
|
|
138
|
+
|
|
139
|
+
[,bash]
|
|
140
|
+
----
|
|
141
|
+
# 1. Check current version in antora.yml
|
|
142
|
+
cat antora.yml | grep latest-connect-version
|
|
143
|
+
|
|
144
|
+
# 2. Generate connector docs for new version
|
|
145
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
146
|
+
--fetch-connectors \
|
|
147
|
+
--draft-missing
|
|
148
|
+
|
|
149
|
+
# 3. Review changes
|
|
150
|
+
git status
|
|
151
|
+
git diff docs-data/
|
|
152
|
+
git diff modules/components/
|
|
153
|
+
|
|
154
|
+
# 4. Commit
|
|
155
|
+
git add docs-data/ modules/components/
|
|
156
|
+
git commit -m "docs: Update Connect to v4.54.0"
|
|
157
|
+
----
|
|
158
|
+
|
|
159
|
+
==== Generating connector documentation manually
|
|
160
|
+
|
|
161
|
+
You can generate connector documentation with various options:
|
|
162
|
+
|
|
163
|
+
[,bash]
|
|
164
|
+
----
|
|
165
|
+
# Basic generation with fetching latest data
|
|
166
|
+
npx doc-tools generate rpcn-connector-docs --fetch-connectors
|
|
167
|
+
|
|
168
|
+
# Generate with custom overrides for descriptions/examples
|
|
169
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
170
|
+
--fetch-connectors \
|
|
171
|
+
--overrides overrides.json
|
|
172
|
+
|
|
173
|
+
# Draft full pages for connectors missing documentation
|
|
174
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
175
|
+
--fetch-connectors \
|
|
176
|
+
--draft-missing \
|
|
177
|
+
--csv internal/plugins/info.csv
|
|
178
|
+
|
|
179
|
+
# Use existing data file from docs-data directory
|
|
180
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
181
|
+
--data-dir docs-data
|
|
182
|
+
|
|
183
|
+
# Generate diff comparing with specific old version
|
|
184
|
+
npx doc-tools generate rpcn-connector-docs \
|
|
185
|
+
--fetch-connectors \
|
|
186
|
+
--old-data docs-data/connect-4.52.0.json
|
|
187
|
+
----
|
|
188
|
+
|
|
189
|
+
**Available options:**
|
|
190
|
+
|
|
191
|
+
* `--fetch-connectors` - Fetch latest data using `rpk connect list`
|
|
192
|
+
* `--draft-missing` - Generate full draft pages for undocumented connectors
|
|
193
|
+
* `--overrides <path>` - Apply custom descriptions/examples from JSON
|
|
194
|
+
* `--data-dir <path>` - Directory containing versioned connect JSON files
|
|
195
|
+
* `--old-data <path>` - Specific old version file for diff comparison
|
|
196
|
+
* `--csv <path>` - Connector metadata CSV (default: `internal/plugins/info.csv`)
|
|
197
|
+
* `--include-bloblang` - Include Bloblang functions/methods
|
|
198
|
+
|
|
199
|
+
==== Checking connector availability
|
|
200
|
+
|
|
201
|
+
The automation fetches and parses the connector catalog CSV from the Redpanda Connect repository:
|
|
202
|
+
|
|
203
|
+
[,bash]
|
|
204
|
+
----
|
|
205
|
+
# View connector catalog (requires build)
|
|
206
|
+
cat modules/components/partials/connector-catalog.csv
|
|
207
|
+
----
|
|
208
|
+
|
|
209
|
+
This catalog includes:
|
|
210
|
+
|
|
211
|
+
* Connector name and type (input/output/processor)
|
|
212
|
+
* Support level (certified, community, experimental)
|
|
213
|
+
* Cloud availability
|
|
214
|
+
* Deprecated status
|
|
215
|
+
* Documentation URLs
|
|
216
|
+
|
|
217
|
+
== How it works
|
|
218
|
+
|
|
219
|
+
=== Architecture overview
|
|
220
|
+
|
|
221
|
+
[,text]
|
|
222
|
+
----
|
|
223
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
224
|
+
│ doc-tools CLI │
|
|
225
|
+
│ └─ generate rpcn-connector-docs command │
|
|
226
|
+
└────────────────────┬────────────────────────────────────────┘
|
|
227
|
+
│
|
|
228
|
+
▼
|
|
229
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
230
|
+
│ Connector Documentation Pipeline │
|
|
231
|
+
├─────────────────────────────────────────────────────────────┤
|
|
232
|
+
│ │
|
|
233
|
+
│ 1. Fetch connector data using rpk connect │
|
|
234
|
+
│ └─ Runs: rpk connect list --format json-full │
|
|
235
|
+
│ └─ Saves: docs-data/connect-<version>.json │
|
|
236
|
+
│ │
|
|
237
|
+
│ 2. Check version match (skip if same as antora.yml) │
|
|
238
|
+
│ └─ Compare: rpk version vs latest-connect-version │
|
|
239
|
+
│ └─ Exit early if versions match │
|
|
240
|
+
│ │
|
|
241
|
+
│ 3. Generate AsciiDoc partials for each connector │
|
|
242
|
+
│ ├─ Apply overrides (custom descriptions/examples) │
|
|
243
|
+
│ ├─ Resolve $ref references │
|
|
244
|
+
│ ├─ Render fields using Handlebars templates │
|
|
245
|
+
│ └─ Output: modules/components/partials/fields/ │
|
|
246
|
+
│ │
|
|
247
|
+
│ 4. Generate diff report (if versions differ) │
|
|
248
|
+
│ ├─ Compare old vs new connector schemas │
|
|
249
|
+
│ ├─ Identify new/removed connectors and fields │
|
|
250
|
+
│ └─ Output: docs-data/connect-diff-X_to_Y.json │
|
|
251
|
+
│ │
|
|
252
|
+
│ 5. Update version in antora.yml (if versions differ) │
|
|
253
|
+
│ └─ Set: latest-connect-version attribute │
|
|
254
|
+
│ │
|
|
255
|
+
└─────────────────────┬───────────────────────────────────────┘
|
|
256
|
+
│
|
|
257
|
+
▼
|
|
258
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
259
|
+
│ Antora Build Process │
|
|
260
|
+
├─────────────────────────────────────────────────────────────┤
|
|
261
|
+
│ │
|
|
262
|
+
│ Extensions: │
|
|
263
|
+
│ • generate-rp-connect-info │
|
|
264
|
+
│ └─ Fetches connector catalog CSV │
|
|
265
|
+
│ └─ Enriches with documentation URLs │
|
|
266
|
+
│ └─ Attaches to component attributes │
|
|
267
|
+
│ │
|
|
268
|
+
│ • generate-rp-connect-categories │
|
|
269
|
+
│ └─ Generates category pages by type │
|
|
270
|
+
│ └─ Sorts connectors by support level │
|
|
271
|
+
│ │
|
|
272
|
+
│ • modify-connect-tag-playbook │
|
|
273
|
+
│ └─ Manages version tracking │
|
|
274
|
+
│ └─ Detects version changes │
|
|
275
|
+
│ └─ Skips processing if version matches │
|
|
276
|
+
│ │
|
|
277
|
+
└─────────────────────────────────────────────────────────────┘
|
|
278
|
+
----
|
|
279
|
+
|
|
280
|
+
=== What gets generated
|
|
281
|
+
|
|
282
|
+
==== 1. Connector documentation
|
|
283
|
+
|
|
284
|
+
Component schemas are fetched from the Redpanda Connect repository and transformed into AsciiDoc:
|
|
285
|
+
|
|
286
|
+
[,json]
|
|
287
|
+
----
|
|
288
|
+
{
|
|
289
|
+
"name": "kafka_franz",
|
|
290
|
+
"type": "input",
|
|
291
|
+
"config": {
|
|
292
|
+
"children": [
|
|
293
|
+
{
|
|
294
|
+
"name": "seed_brokers",
|
|
295
|
+
"type": "string",
|
|
296
|
+
"kind": "array",
|
|
297
|
+
"description": "A list of broker addresses..."
|
|
298
|
+
}
|
|
299
|
+
]
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
----
|
|
303
|
+
|
|
304
|
+
Generates:
|
|
305
|
+
|
|
306
|
+
[,asciidoc]
|
|
307
|
+
----
|
|
308
|
+
=== `seed_brokers`
|
|
309
|
+
|
|
310
|
+
A list of broker addresses to connect to.
|
|
311
|
+
|
|
312
|
+
*Type:* `string[]`
|
|
313
|
+
|
|
314
|
+
*Examples:*
|
|
315
|
+
|
|
316
|
+
[source,yaml]
|
|
317
|
+
----
|
|
318
|
+
seed_brokers:
|
|
319
|
+
- localhost:9092
|
|
320
|
+
- broker1:9092
|
|
321
|
+
----
|
|
322
|
+
----
|
|
323
|
+
|
|
324
|
+
==== 2. Connector catalog
|
|
325
|
+
|
|
326
|
+
The CSV catalog from the Connect repository is parsed and enriched:
|
|
327
|
+
|
|
328
|
+
[,csv]
|
|
329
|
+
----
|
|
330
|
+
name,type,commercial_name,version,support,cloud,deprecated
|
|
331
|
+
kafka_franz,input,Apache Kafka,4.53.0,certified,y,n
|
|
332
|
+
elasticsearch_v8,output,Elasticsearch,4.53.0,certified,y,n
|
|
333
|
+
----
|
|
334
|
+
|
|
335
|
+
Enriched with documentation URLs and support metadata:
|
|
336
|
+
|
|
337
|
+
[,json]
|
|
338
|
+
----
|
|
339
|
+
{
|
|
340
|
+
"connector": "kafka_franz",
|
|
341
|
+
"type": "input",
|
|
342
|
+
"support_level": "certified",
|
|
343
|
+
"is_cloud_supported": "y",
|
|
344
|
+
"redpandaConnectUrl": "/connect/components/inputs/kafka_franz",
|
|
345
|
+
"redpandaCloudUrl": "/cloud/connect/components/inputs/kafka_franz"
|
|
346
|
+
}
|
|
347
|
+
----
|
|
348
|
+
|
|
349
|
+
=== Key transformations
|
|
350
|
+
|
|
351
|
+
==== Version detection and matching
|
|
352
|
+
|
|
353
|
+
The automation detects the current Connect version from `antora.yml`:
|
|
354
|
+
|
|
355
|
+
[,javascript]
|
|
356
|
+
----
|
|
357
|
+
const currentVersion = getAntoraValue(antoraYmlPath, 'asciidoc.attributes.latest-connect-version');
|
|
358
|
+
const fetchedVersion = await getRpkConnectVersion(tag);
|
|
359
|
+
|
|
360
|
+
if (currentVersion === fetchedVersion) {
|
|
361
|
+
console.log(`✓ Already at version ${fetchedVersion}, skipping diff and updates`);
|
|
362
|
+
process.exit(0);
|
|
363
|
+
}
|
|
364
|
+
----
|
|
365
|
+
|
|
366
|
+
==== Connector documentation generation
|
|
367
|
+
|
|
368
|
+
Uses Handlebars templates to render component fields and examples:
|
|
369
|
+
|
|
370
|
+
[,handlebars]
|
|
371
|
+
----
|
|
372
|
+
{{#each config.children}}
|
|
373
|
+
=== `{{name}}`
|
|
374
|
+
|
|
375
|
+
{{description}}
|
|
376
|
+
|
|
377
|
+
*Type:* `{{type}}`
|
|
378
|
+
|
|
379
|
+
{{#if default}}
|
|
380
|
+
*Default:* `{{formatValue default type}}`
|
|
381
|
+
{{/if}}
|
|
382
|
+
|
|
383
|
+
{{#if examples}}
|
|
384
|
+
*Examples:*
|
|
385
|
+
|
|
386
|
+
{{#each examples}}
|
|
387
|
+
[source,yaml]
|
|
388
|
+
----
|
|
389
|
+
{{this}}
|
|
390
|
+
----
|
|
391
|
+
{{/each}}
|
|
392
|
+
{{/if}}
|
|
393
|
+
|
|
394
|
+
{{/each}}
|
|
395
|
+
----
|
|
396
|
+
|
|
397
|
+
== Understanding the codebase
|
|
398
|
+
|
|
399
|
+
=== Project structure
|
|
400
|
+
|
|
401
|
+
[,text]
|
|
402
|
+
----
|
|
403
|
+
tools/redpanda-connect/
|
|
404
|
+
├── generate-rpcn-connector-docs.js # Main connector doc generator
|
|
405
|
+
├── parse-csv-connectors.js # CSV catalog parser
|
|
406
|
+
├── report-delta.js # Version comparison
|
|
407
|
+
├── helpers/
|
|
408
|
+
│ ├── renderConnectFields.js # Renders field documentation
|
|
409
|
+
│ ├── renderConnectExamples.js # Renders examples
|
|
410
|
+
│ ├── buildConfigYaml.js # Builds YAML examples
|
|
411
|
+
│ ├── commonConfig.js # Common config helper
|
|
412
|
+
│ ├── advancedConfig.js # Advanced config helper
|
|
413
|
+
│ └── ...
|
|
414
|
+
└── templates/
|
|
415
|
+
├── connector.hbs # Full connector template
|
|
416
|
+
├── fields.hbs # Fields partial
|
|
417
|
+
├── examples.hbs # Examples partial
|
|
418
|
+
└── bloblang-function.hbs # Bloblang function template
|
|
419
|
+
|
|
420
|
+
extensions/
|
|
421
|
+
├── generate-rp-connect-info.js # Fetches and enriches catalog
|
|
422
|
+
├── generate-rp-connect-categories.js # Generates category pages
|
|
423
|
+
└── modify-connect-tag-playbook.js # Version tracking
|
|
424
|
+
----
|
|
425
|
+
|
|
426
|
+
=== Connector documentation generation
|
|
427
|
+
|
|
428
|
+
The `generateRpcnConnectorDocs()` function processes component schemas:
|
|
429
|
+
|
|
430
|
+
1. **Load data**: Read component schemas (JSON or YAML)
|
|
431
|
+
2. **Apply overrides**: Merge custom descriptions and examples
|
|
432
|
+
3. **Resolve references**: Expand `$ref` pointers
|
|
433
|
+
4. **Mark beta features**: Detect and flag beta components
|
|
434
|
+
5. **Render templates**: Generate AsciiDoc using Handlebars
|
|
435
|
+
6. **Write outputs**: Create partials, examples, and drafts
|
|
436
|
+
|
|
437
|
+
**Key parameters:**
|
|
438
|
+
|
|
439
|
+
* `data` - Path to component schema file
|
|
440
|
+
* `overrides` - Optional overrides JSON
|
|
441
|
+
* `template` - Main template (for full drafts)
|
|
442
|
+
* `templateFields` - Fields partial template
|
|
443
|
+
* `templateExamples` - Examples partial template
|
|
444
|
+
* `writeFullDrafts` - Generate full pages vs partials
|
|
445
|
+
|
|
446
|
+
=== Version tracking
|
|
447
|
+
|
|
448
|
+
The `modify-connect-tag-playbook` extension manages version detection:
|
|
449
|
+
|
|
450
|
+
[,javascript]
|
|
451
|
+
----
|
|
452
|
+
// Detect current version
|
|
453
|
+
const currentVersion = contentCatalog
|
|
454
|
+
.getComponent('redpanda-connect')
|
|
455
|
+
.latest.asciidoc.attributes['latest-connect-version'];
|
|
456
|
+
|
|
457
|
+
// Fetch new version from repository
|
|
458
|
+
const newVersion = await getRpkConnectVersion(tag);
|
|
459
|
+
|
|
460
|
+
// Compare and skip if match
|
|
461
|
+
if (currentVersion === newVersion) {
|
|
462
|
+
logger.info(`Already at version ${newVersion}`);
|
|
463
|
+
return; // Skip diff and updates
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
// Generate diff and update antora.yml
|
|
467
|
+
const delta = compareVersions(currentVersion, newVersion);
|
|
468
|
+
await updateAntoraVersion(newVersion);
|
|
469
|
+
----
|
|
470
|
+
|
|
471
|
+
=== Override system
|
|
472
|
+
|
|
473
|
+
Overrides allow customizing extracted documentation:
|
|
474
|
+
|
|
475
|
+
[,json]
|
|
476
|
+
----
|
|
477
|
+
{
|
|
478
|
+
"$comment": "Custom descriptions and examples for Connect components",
|
|
479
|
+
"definitions": {
|
|
480
|
+
"client_certs": {
|
|
481
|
+
"description": "A list of client certificates to use for mTLS..."
|
|
482
|
+
}
|
|
483
|
+
},
|
|
484
|
+
"inputs": [
|
|
485
|
+
{
|
|
486
|
+
"name": "kafka_franz",
|
|
487
|
+
"config": {
|
|
488
|
+
"children": [
|
|
489
|
+
{
|
|
490
|
+
"name": "seed_brokers",
|
|
491
|
+
"$ref": "#/definitions/seed_brokers_description"
|
|
492
|
+
}
|
|
493
|
+
]
|
|
494
|
+
},
|
|
495
|
+
"examples": [
|
|
496
|
+
{
|
|
497
|
+
"title": "Basic Kafka consumer",
|
|
498
|
+
"summary": "Connect to a Kafka broker and consume messages",
|
|
499
|
+
"config": "input:\n kafka_franz:\n seed_brokers:\n - localhost:9092"
|
|
500
|
+
}
|
|
501
|
+
]
|
|
502
|
+
}
|
|
503
|
+
]
|
|
504
|
+
}
|
|
505
|
+
----
|
|
506
|
+
|
|
507
|
+
Overrides support:
|
|
508
|
+
|
|
509
|
+
* `description` - Replace auto-extracted descriptions
|
|
510
|
+
* `examples` - Add usage examples
|
|
511
|
+
* `$ref` - JSON Pointer references for reusable content
|
|
512
|
+
* `annotated_options` - Add human-readable enum descriptions
|
|
513
|
+
|
|
514
|
+
== Limitations and known issues
|
|
515
|
+
|
|
516
|
+
=== What works well
|
|
517
|
+
|
|
518
|
+
* Standard component schema extraction
|
|
519
|
+
* Connector catalog enrichment
|
|
520
|
+
* Version tracking and change detection
|
|
521
|
+
* Handlebars template rendering
|
|
522
|
+
* Override system for custom documentation
|
|
523
|
+
|
|
524
|
+
=== Current limitations
|
|
525
|
+
|
|
526
|
+
* *Manual override maintenance*: Custom descriptions must be maintained in overrides.json
|
|
527
|
+
* *Example quality*: Auto-generated examples may not represent best practices
|
|
528
|
+
* *Duplicate YAML keys*: Some examples contain multiple configurations in one block, creating invalid YAML with duplicate top-level keys (e.g., multiple `processors:` keys)
|
|
529
|
+
* *CSV catalog dependency*: Relies on manually maintained CSV in Connect repository
|
|
530
|
+
* *Version detection timing*: Must be called during Antora build to access component attributes
|
|
531
|
+
|
|
532
|
+
=== Known issues
|
|
533
|
+
|
|
534
|
+
==== Duplicate keys in examples
|
|
535
|
+
|
|
536
|
+
Multiple Connect component examples contain duplicate top-level YAML keys, which is invalid YAML:
|
|
537
|
+
|
|
538
|
+
[,yaml]
|
|
539
|
+
----
|
|
540
|
+
# Invalid: Two processors: keys
|
|
541
|
+
pipeline:
|
|
542
|
+
processors: # First occurrence
|
|
543
|
+
- branch:
|
|
544
|
+
request_map: 'root = ""'
|
|
545
|
+
processors: # Second occurrence (nested, OK)
|
|
546
|
+
- http:
|
|
547
|
+
url: example.com
|
|
548
|
+
|
|
549
|
+
processors: # Third occurrence (DUPLICATE - INVALID)
|
|
550
|
+
- mapping: |
|
|
551
|
+
root = content().uppercase()
|
|
552
|
+
----
|
|
553
|
+
|
|
554
|
+
This occurs when multiple separate configurations are concatenated into a single example. These should be split into separate examples or restructured.
|
|
555
|
+
|
|
556
|
+
=== Workarounds
|
|
557
|
+
|
|
558
|
+
For unsupported patterns or issues, use overrides.json:
|
|
559
|
+
|
|
560
|
+
[,json]
|
|
561
|
+
----
|
|
562
|
+
{
|
|
563
|
+
"inputs": [
|
|
564
|
+
{
|
|
565
|
+
"name": "problematic_connector",
|
|
566
|
+
"description": "Custom description overriding auto-extracted text",
|
|
567
|
+
"examples": [
|
|
568
|
+
{
|
|
569
|
+
"title": "Corrected example",
|
|
570
|
+
"config": "input:\n problematic_connector:\n field: value"
|
|
571
|
+
}
|
|
572
|
+
]
|
|
573
|
+
}
|
|
574
|
+
]
|
|
575
|
+
}
|
|
576
|
+
----
|
|
577
|
+
|
|
578
|
+
== Contributing
|
|
579
|
+
|
|
580
|
+
=== Development setup
|
|
581
|
+
|
|
582
|
+
[,bash]
|
|
583
|
+
----
|
|
584
|
+
# Clone repository
|
|
585
|
+
git clone https://github.com/redpanda-data/docs-extensions-and-macros.git
|
|
586
|
+
cd docs-extensions-and-macros
|
|
587
|
+
|
|
588
|
+
# Install dependencies
|
|
589
|
+
npm install
|
|
590
|
+
|
|
591
|
+
# Test connector doc generation
|
|
592
|
+
npm test -- __tests__/tools/generate-rpcn-connector-docs.test.js
|
|
593
|
+
----
|
|
594
|
+
|
|
595
|
+
=== Making changes
|
|
596
|
+
|
|
597
|
+
1. **Before you start:**
|
|
598
|
+
- Open an issue describing the problem/enhancement
|
|
599
|
+
- Discuss approach with maintainers
|
|
600
|
+
|
|
601
|
+
2. **Make your changes:**
|
|
602
|
+
- Follow existing code style
|
|
603
|
+
- Add tests for new functionality
|
|
604
|
+
- Update this README for significant changes
|
|
605
|
+
|
|
606
|
+
3. **Test thoroughly:**
|
|
607
|
+
- Run existing tests: `npm test`
|
|
608
|
+
- Test on actual Connect schemas
|
|
609
|
+
- Verify generated AsciiDoc renders correctly
|
|
610
|
+
|
|
611
|
+
4. **Submit PR:**
|
|
612
|
+
- Include issue reference
|
|
613
|
+
- Describe what changed and why
|
|
614
|
+
- Show before/after examples
|
|
615
|
+
|
|
616
|
+
=== Testing checklist
|
|
617
|
+
|
|
618
|
+
Before submitting changes, verify:
|
|
619
|
+
|
|
620
|
+
* [ ] All tests pass: `npm test`
|
|
621
|
+
* [ ] Generated docs look correct when built with Antora
|
|
622
|
+
* [ ] Override handling still works
|
|
623
|
+
* [ ] Version detection correctly skips when versions match
|
|
624
|
+
* [ ] Templates render without errors
|
|
625
|
+
* [ ] No regression on existing connectors
|
|
626
|
+
|
|
627
|
+
=== Code style guidelines
|
|
628
|
+
|
|
629
|
+
*JavaScript:*
|
|
630
|
+
|
|
631
|
+
* Use modern ES6+ features
|
|
632
|
+
* Prefer const/let over var
|
|
633
|
+
* Document helper functions with JSDoc
|
|
634
|
+
* Use async/await over callbacks
|
|
635
|
+
|
|
636
|
+
*Handlebars templates:*
|
|
637
|
+
|
|
638
|
+
* Keep logic minimal - move complex logic to helpers
|
|
639
|
+
* Use descriptive helper names
|
|
640
|
+
* Comment non-obvious template sections
|
|
641
|
+
|
|
642
|
+
*Documentation:*
|
|
643
|
+
|
|
644
|
+
* Use AsciiDoc format
|
|
645
|
+
* Include code examples
|
|
646
|
+
* Explain the "why" not just the "what"
|
|
647
|
+
* Keep README in sync with code
|
|
648
|
+
|
|
649
|
+
== Troubleshooting
|
|
650
|
+
|
|
651
|
+
=== Generation issues
|
|
652
|
+
|
|
653
|
+
**Connector not generated:**
|
|
654
|
+
|
|
655
|
+
1. Verify connector exists in schema:
|
|
656
|
+
+
|
|
657
|
+
[,bash]
|
|
658
|
+
----
|
|
659
|
+
cat connect-schema.json | jq '.inputs[] | select(.name=="connector_name")'
|
|
660
|
+
----
|
|
661
|
+
|
|
662
|
+
2. Check if connector is deprecated (skipped in draft mode)
|
|
663
|
+
|
|
664
|
+
3. Add override to force generation
|
|
665
|
+
|
|
666
|
+
**Invalid AsciiDoc output:**
|
|
667
|
+
|
|
668
|
+
1. Check template syntax:
|
|
669
|
+
+
|
|
670
|
+
[,bash]
|
|
671
|
+
----
|
|
672
|
+
node -e "const h = require('handlebars'); h.compile(require('fs').readFileSync('template.hbs', 'utf8'))"
|
|
673
|
+
----
|
|
674
|
+
|
|
675
|
+
2. Verify data structure matches template expectations
|
|
676
|
+
|
|
677
|
+
3. Test with minimal example data
|
|
678
|
+
|
|
679
|
+
**Version detection fails:**
|
|
680
|
+
|
|
681
|
+
1. Verify antora.yml exists at repository root
|
|
682
|
+
|
|
683
|
+
2. Check attribute name matches:
|
|
684
|
+
+
|
|
685
|
+
[,bash]
|
|
686
|
+
----
|
|
687
|
+
cat antora.yml | grep latest-connect-version
|
|
688
|
+
----
|
|
689
|
+
|
|
690
|
+
3. Ensure modify-connect-tag-playbook extension is registered
|
|
691
|
+
|
|
692
|
+
=== Template rendering issues
|
|
693
|
+
|
|
694
|
+
**Handlebars error:**
|
|
695
|
+
|
|
696
|
+
[,bash]
|
|
697
|
+
----
|
|
698
|
+
# Validate JSON data
|
|
699
|
+
jq . generated.json
|
|
700
|
+
|
|
701
|
+
# Test template manually
|
|
702
|
+
node -e "const hbs = require('handlebars'); const fs = require('fs'); const tpl = hbs.compile(fs.readFileSync('template.hbs', 'utf8')); console.log(tpl(JSON.parse(fs.readFileSync('data.json', 'utf8'))))"
|
|
703
|
+
----
|
|
704
|
+
|
|
705
|
+
**Missing values in output:**
|
|
706
|
+
|
|
707
|
+
1. Check data has required field in JSON
|
|
708
|
+
2. Verify template references correct field name
|
|
709
|
+
3. Test with minimal data to isolate issue
|
|
710
|
+
|
|
711
|
+
**Helper not found:**
|
|
712
|
+
|
|
713
|
+
1. Verify helper is registered:
|
|
714
|
+
+
|
|
715
|
+
[,javascript]
|
|
716
|
+
----
|
|
717
|
+
// In generate-rpcn-connector-docs.js
|
|
718
|
+
Object.entries(helpers).forEach(([name, fn]) => {
|
|
719
|
+
handlebars.registerHelper(name, fn);
|
|
720
|
+
});
|
|
721
|
+
----
|
|
722
|
+
|
|
723
|
+
2. Check helper is exported from helpers/index.js
|
|
724
|
+
|
|
725
|
+
3. Ensure helper function exists
|
|
726
|
+
|
|
727
|
+
== Additional resources
|
|
728
|
+
|
|
729
|
+
* https://github.com/redpanda-data/connect[Redpanda Connect Repository]
|
|
730
|
+
* https://github.com/redpanda-data/docs-extensions-and-macros[docs-extensions-and-macros Repository]
|
|
731
|
+
* https://handlebarsjs.com/[Handlebars.js Documentation]
|
|
732
|
+
* https://docs.asciidoctor.org/asciidoc/latest/[AsciiDoc Language Documentation]
|
|
733
|
+
|
|
734
|
+
== License
|
|
735
|
+
|
|
736
|
+
See LICENSE file in repository root.
|