@redpanda-data/docs-extensions-and-macros 4.12.5 → 4.13.0

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.
Files changed (62) hide show
  1. package/README.adoc +33 -1064
  2. package/bin/doc-tools-mcp.js +720 -0
  3. package/bin/doc-tools.js +1050 -50
  4. package/bin/mcp-tools/antora.js +153 -0
  5. package/bin/mcp-tools/cache.js +89 -0
  6. package/bin/mcp-tools/cloud-regions.js +127 -0
  7. package/bin/mcp-tools/content-review.js +196 -0
  8. package/bin/mcp-tools/crd-docs.js +153 -0
  9. package/bin/mcp-tools/frontmatter.js +138 -0
  10. package/bin/mcp-tools/generated-docs-review.js +887 -0
  11. package/bin/mcp-tools/helm-docs.js +152 -0
  12. package/bin/mcp-tools/index.js +245 -0
  13. package/bin/mcp-tools/job-queue.js +468 -0
  14. package/bin/mcp-tools/mcp-validation.js +266 -0
  15. package/bin/mcp-tools/metrics-docs.js +146 -0
  16. package/bin/mcp-tools/openapi.js +174 -0
  17. package/bin/mcp-tools/prompt-discovery.js +283 -0
  18. package/bin/mcp-tools/property-docs.js +157 -0
  19. package/bin/mcp-tools/rpcn-docs.js +113 -0
  20. package/bin/mcp-tools/rpk-docs.js +141 -0
  21. package/bin/mcp-tools/telemetry.js +211 -0
  22. package/bin/mcp-tools/utils.js +131 -0
  23. package/bin/mcp-tools/versions.js +168 -0
  24. package/cli-utils/convert-doc-links.js +1 -1
  25. package/cli-utils/github-token.js +58 -0
  26. package/cli-utils/self-managed-docs-branch.js +2 -2
  27. package/cli-utils/setup-mcp.js +313 -0
  28. package/docker-compose/25.1/transactions.md +1 -1
  29. package/docker-compose/transactions.md +1 -1
  30. package/extensions/DEVELOPMENT.adoc +464 -0
  31. package/extensions/README.adoc +124 -0
  32. package/extensions/REFERENCE.adoc +768 -0
  33. package/extensions/USER_GUIDE.adoc +339 -0
  34. package/extensions/generate-rp-connect-info.js +3 -4
  35. package/extensions/version-fetcher/get-latest-console-version.js +38 -27
  36. package/extensions/version-fetcher/get-latest-redpanda-helm-version-from-operator.js +1 -1
  37. package/extensions/version-fetcher/get-latest-redpanda-version.js +65 -54
  38. package/extensions/version-fetcher/retry-util.js +88 -0
  39. package/extensions/version-fetcher/set-latest-version.js +6 -3
  40. package/macros/DEVELOPMENT.adoc +377 -0
  41. package/macros/README.adoc +105 -0
  42. package/macros/REFERENCE.adoc +222 -0
  43. package/macros/USER_GUIDE.adoc +220 -0
  44. package/macros/rp-connect-components.js +6 -6
  45. package/package.json +12 -3
  46. package/tools/bundle-openapi.js +20 -10
  47. package/tools/cloud-regions/generate-cloud-regions.js +1 -1
  48. package/tools/fetch-from-github.js +18 -4
  49. package/tools/gen-rpk-ascii.py +3 -1
  50. package/tools/generate-cli-docs.js +325 -0
  51. package/tools/get-console-version.js +4 -2
  52. package/tools/get-redpanda-version.js +4 -2
  53. package/tools/metrics/metrics.py +19 -7
  54. package/tools/property-extractor/Makefile +7 -1
  55. package/tools/property-extractor/cloud_config.py +4 -4
  56. package/tools/property-extractor/constant_resolver.py +11 -11
  57. package/tools/property-extractor/property_extractor.py +18 -16
  58. package/tools/property-extractor/topic_property_extractor.py +2 -2
  59. package/tools/property-extractor/transformers.py +7 -7
  60. package/tools/property-extractor/type_definition_extractor.py +4 -4
  61. package/tools/redpanda-connect/README.adoc +1 -1
  62. package/tools/redpanda-connect/generate-rpcn-connector-docs.js +5 -3
@@ -0,0 +1,768 @@
1
+ = Antora extensions reference
2
+ :toc:
3
+ :toclevels: 3
4
+
5
+ Reference documentation for all Antora extensions provided by this library.
6
+
7
+ IMPORTANT: Ensure you register each extension under the `antora.extensions` key in the playbook, not the `asciidoc.extensions` key.
8
+
9
+ == Add Bloblang samples to pages
10
+
11
+ The `collect-bloblang-samples` extension processes Bloblang examples from YAML files in the `examples` directory of the `redpanda-connect` component. This extension ensures that these examples are accessible as structured data for use in UI components or documentation, such as sample dropdowns in a Bloblang playground.
12
+
13
+ It validates, sorts, and attaches the processed examples as a JSON object to the Antora page attributes. The extension ensures examples have unique titles, mandatory fields (`input` and `mapping`), and are sorted in alphabetical order.
14
+
15
+ The processed examples are added as JSON to the `page-bloblang-samples` attribute. For example:
16
+
17
+ [,json]
18
+ ----
19
+ {
20
+ "hello-world.yaml": {
21
+ "title": "Hello world",
22
+ "input": "{\n \"message\": \"hello world\"\n}\n",
23
+ "mapping": "root.message = this.message.uppercase()\n"
24
+ },
25
+ "array-processing.yaml": {
26
+ "title": "Array processing",
27
+ "input": "{\n \"numbers\": [1, 2, 3, 4, 5]\n}\n",
28
+ "mapping": "root.even_numbers = this.numbers.filter(n -> n % 2 == 0)"
29
+ }
30
+ }
31
+ ----
32
+
33
+ === Environment variables
34
+
35
+ This extension does not require any environment variables.
36
+
37
+ === Configuration options
38
+
39
+ To enable the extension, add it to your Antora playbook under the `antora.extensions` key. No additional configuration is required.
40
+
41
+ [,yaml]
42
+ ----
43
+ antora:
44
+ extensions:
45
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/collect-bloblang-samples'
46
+ ----
47
+
48
+ === Example Bloblang YAML file
49
+
50
+ The following YAML file is an example of how to define a Bloblang sample:
51
+
52
+ [,yaml]
53
+ ----
54
+ title: Hello world
55
+ input: |
56
+ {
57
+ "message": "hello world"
58
+ }
59
+ mapping: |
60
+ root.message = this.message.uppercase()
61
+ ----
62
+
63
+ == Add pages to root
64
+
65
+ The `add-pages-to-root` extension allows you to copy files from your Antora content catalog to the root of the site during the build process. This is particularly useful for files like `llms.txt` or any custom files that need to be directly accessible at the site's root level.
66
+
67
+ This extension processes a list of file paths provided in the playbook configuration, locates those files in the Antora content catalog, and adds them to the site's root directory during the publishing phase. Each file's content and basename are preserved in the process.
68
+
69
+ === Environment variables
70
+
71
+ This extension does not require any environment variables.
72
+
73
+ === Configuration options
74
+
75
+ Add the `add-pages-to-root` extension to your Antora playbook under the `antora.extensions` key, and specify the list of files to process in the `files` configuration.
76
+
77
+ [source,yaml]
78
+ ----
79
+ antora:
80
+ extensions:
81
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/add-pages-to-root'
82
+ files:
83
+ - home:ROOT:attachment$custom-file.txt
84
+ ----
85
+
86
+ === Registration
87
+
88
+ [source,yaml]
89
+ ----
90
+ antora:
91
+ extensions:
92
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/add-pages-to-root'
93
+ files:
94
+ - home:ROOT:attachment$custom-file.txt
95
+ ----
96
+
97
+ == Algolia indexer
98
+
99
+ This extension generates an Algolia index for each version of each component. The index entries are then saved to Algolia using the `saveObjects()` method, and also saved as JSON files in the site catalog. JSON files are published to the site root using the template `algolia-<component>-<version>.json`.
100
+
101
+ NOTE: Only pages that include an `<article>` element with the `doc` class are indexed.
102
+
103
+ === Environment variables
104
+
105
+ - `ALGOLIA_ADMIN_API_KEY` (required)
106
+ - `ALGOLIA_APP_ID` (required)
107
+ - `ALGOLIA_INDEX_NAME` (required)
108
+
109
+ === Configuration options
110
+
111
+ The extension accepts the following configuration options:
112
+
113
+ excludes (optional)::
114
+ Any elements, classes, or IDs that you want to exclude from the index.
115
+ index-latest-only (optional)::
116
+ Whether to index all versions or just the latest version of a component.
117
+
118
+ === Registration
119
+
120
+ ```yaml
121
+ antora:
122
+ extensions:
123
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/algolia-indexer/index'
124
+ excludes: ['.thumbs','script', '.page-versions','.feedback-section','.banner-container']
125
+ index-latest-only: true
126
+ ```
127
+
128
+ == Archive attachments
129
+
130
+ The `archive-attachments` extension automates the packaging of specific attachment files into a compressed archive (`.tar.gz`) based on configurable patterns. This archive is then made available to the generated site, allowing users to easily download grouped resources such as Docker Compose configurations.
131
+
132
+ This extension enables you to define which files and directories to include in the archive, ensuring that only relevant content is packaged and accessible.
133
+
134
+ === Environment variables
135
+
136
+ This extension does not require any environment variables.
137
+
138
+ === Configuration options
139
+
140
+ The extension accepts the following options in the Antora playbook.
141
+
142
+ Configure the extension in your Antora playbook by defining an array of archive configurations under `data.archives`. Each archive configuration includes:
143
+
144
+ output_archive (string, required):: The name of the generated archive file.
145
+
146
+ component (string, required):: The name of the Antora component whose attachments should be archived.
147
+
148
+ file_patterns (array of strings, required):: Glob patterns specifying which attachment paths to include in the archive.
149
+
150
+ NOTE: Ensure that `file_patterns` accurately reflect the paths of the attachments you want to archive. Overly broad patterns may include unintended files, while overly restrictive patterns might exclude necessary resources.
151
+
152
+ === Example configuration
153
+
154
+ Here's an example configuration to enable the extension:
155
+
156
+ ```yaml
157
+ antora:
158
+ extensions:
159
+ - require: '../docs-extensions-and-macros/extensions/archive-creation-extension.js'
160
+ data:
161
+ archives:
162
+ - output_archive: 'redpanda-quickstart.tar.gz' <1>
163
+ component: 'ROOT' <2>
164
+ file_patterns:
165
+ - '**/test-resources/**/docker-compose/**' <3>
166
+ ```
167
+
168
+ <1> Defines the name of the generated archive placed at the site root.
169
+ <2> Defines the name of the component in which to search for attachments.
170
+ <3> Lists the glob patterns to match attachment paths for inclusion in the archive.
171
+ +
172
+ - `**`: Matches any number of directories.
173
+ - `/test-resources/`: Specifies that the matching should occur within the `test-resources/` directory.
174
+ - `/docker-compose/`: Targets the `docker-compose/` directory and all its subdirectories.
175
+ - `**:` Ensures that all files and nested directories within `docker-compose/` are included.
176
+
177
+ == Behavior with multiple components/versions
178
+
179
+ *Scenario*: Multiple components and/or multiple versions of the same component contain attachments that match the defined file_patterns.
180
+
181
+ *Outcome*: Separate archives for each component version.
182
+
183
+ For each matching (component, version) pair, the extension creates a distinct archive named `<version>-<output_archive>`. For example:
184
+ `24.3-redpanda-quickstart.tar.gz`.
185
+
186
+ These archives are placed at the site root, ensuring they are easily accessible and do not overwrite each other.
187
+
188
+ For the latest version of each component, the extension also adds the archive using the base `output_archive` name. As a result, the latest archives are accessible through a consistent filename, facilitating easy downloads without needing to reference version numbers.
189
+
190
+ Because each archive has a unique filename based on the component version, there is no risk of archives overwriting each other.
191
+ The only exception is the archive for the latest version, which consistently uses the `output_archive` name.
192
+
193
+ == Component category aggregator
194
+
195
+ This extension maps Redpanda Connect component data into a structured format:
196
+
197
+ - Maps original component names to common names.
198
+ - Populates `connectCategoriesData` and `flatComponentsData` attributes.
199
+ - Skips deprecated components.
200
+
201
+ === Environment variables
202
+
203
+ This extension does not require any environment variables.
204
+
205
+ === Configuration options
206
+
207
+ There are no configurable options for this extension.
208
+
209
+ === Registration
210
+
211
+ ```yaml
212
+ antora:
213
+ extensions:
214
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/generate-rp-connect-categories'
215
+ ```
216
+
217
+ == Compute end-of-life extension
218
+
219
+ This extension calculates and attaches metadata related to the end-of-life (EoL) status of docs pages, such as nearing EoL, past EoL, and associated EoL dates. This metadata can be used to display relevant banners or messages in docs to inform users about the lifecycle of each version.
220
+
221
+ The extension leverages configuration settings provided in the Antora playbook to apply EoL calculations, specify the warning period, and include links to upgrade documentation and EoL policies.
222
+
223
+ The extension computes whether a page is nearing EoL or past EoL based on the `page-release-date` attribute and configured settings.
224
+ It injects the following attributes into each page, making them available for use in UI templates:
225
+
226
+ - `page-is-nearing-eol`: Indicates if the page is within the warning period before EoL. Calculated using `(page-release-date + supported_months) - warning_weeks`.
227
+ - `page-is-past-eol`: Indicates if the page has passed its EoL. Calculated using `today > (page-release-date + supported_months)`.
228
+ - `page-eol-date`: The calculated EoL date in a human-readable format. Calculated using `page-release-date + supported_months`.
229
+ - `page-eol-doc`: The URL to the supported versions policy or EoL documentation.
230
+ - `page-upgrade-doc`: The Antora resource ID to a document containing upgrade instructions.
231
+
232
+ === Environment variables
233
+
234
+ This extension does not require any environment variables.
235
+
236
+ === Configuration options
237
+
238
+ To enable and configure the extension, add it to the `antora.extensions` section of your Antora playbook. Define the EoL settings under the `data.eol_settings` key with the following options:
239
+
240
+ `component` (required):: The component name to which the configuration applies.
241
+ `eol_doc` (required):: A link to the supported versions policy or EoL documentation.
242
+ `upgrade_doc` (required):: A link to the upgrade instructions.
243
+ `supported_months` (optional, default: 12):: The number of months after the publish date when the documentation reaches its EoL.
244
+ `warning_weeks` (optional, default: 6):: The number of weeks before EoL when the documentation is considered to be nearing EoL. Can be used to decide when to notify users of the upcoming EoL status.
245
+
246
+ [,yaml]
247
+ ----
248
+ antora:
249
+ extensions:
250
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/compute-end-of-life'
251
+ data:
252
+ eol_settings:
253
+ - component: 'ROOT'
254
+ supported_months: 18
255
+ warning_weeks: 8
256
+ eol_doc: https://support.redpanda.com/hc/en-us/articles/20617574366743-Redpanda-Supported-Versions
257
+ upgrade_doc: ROOT:upgrade:index.adoc
258
+ ----
259
+
260
+ === Registration
261
+
262
+ You can register the extension with a customized configuration for different components in your playbook:
263
+
264
+ [,yaml]
265
+ ----
266
+ antora:
267
+ extensions:
268
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/compute-end-of-life'
269
+ data:
270
+ eol_settings:
271
+ - component: 'ROOT'
272
+ supported_months: 12
273
+ warning_weeks: 6
274
+ eol_doc: https://example.com/supported-versions
275
+ upgrade_doc: ROOT:upgrade:index.adoc
276
+ - component: 'example-docs'
277
+ supported_months: 24
278
+ warning_weeks: 12
279
+ eol_doc: https://example.com/example-supported-versions
280
+ upgrade_doc: example-docs:upgrade:index.adoc
281
+ ----
282
+
283
+
284
+ === Example Handlebars template:
285
+
286
+ [,handlebars]
287
+ ----
288
+ {{#if page.attributes.is-nearing-eol}}
289
+ <div class="banner-container nearing-eol">
290
+ This documentation will reach its end of life on {{page.attributes.eol-date}}.
291
+ Please <a href="{{resolve-resource page.attributes.upgrade-doc}}">upgrade to a supported version</a>.
292
+ </div>
293
+ {{else if page.attributes.is-past-eol}}
294
+ <div class="banner-container past-eol">
295
+ This documentation reached its end of life on {{page.attributes.eol-date}}.
296
+ See our <a href="{{page.attributes.eol-doc}}" target="_blank">supported versions policy</a>.
297
+ </div>
298
+ {{/if}}
299
+ ----
300
+
301
+ == Generate index data
302
+
303
+ The `generate-index-data` extension creates structured index data about doc pages based on configurable filters. The indexed data is saved to a specified attribute in all component versions, enabling the dynamic generation of categorized links and descriptions within your docs using UI templates.
304
+
305
+ This extension allows you to define multiple indexing criteria, such as component, URL filter, and environment type.
306
+
307
+ The generated data is an array of objects, where each object represents a component version. Each object contains the following properties:
308
+
309
+ - `component` (string):
310
+ The name of the Antora component.
311
+
312
+ - `version` (string):
313
+ The version of the component.
314
+
315
+ - `pages` (array):
316
+ A list of pages that match the indexing criteria. Each page contains:
317
+ ** `title` (string): The title of the doc page.
318
+ ** `url` (string): The URL of the doc page relative to the site root.
319
+ ** `description` (string): A brief description sourced from the `:description:` attribute in the AsciiDoc file. Defaults to an empty string if not provided.
320
+
321
+ Example:
322
+
323
+ ```json
324
+ [
325
+ {
326
+ "component": "ROOT",
327
+ "version": "24.3",
328
+ "pages": [
329
+ {
330
+ "title": "Manage Debug Bundles in Redpanda Console",
331
+ "url": "/current/console/ui/generate-bundle/",
332
+ "description": "Learn how to generate, download, and delete debug bundles in Redpanda Console for comprehensive cluster diagnostics."
333
+ },
334
+ ]
335
+ }
336
+ ]
337
+ ```
338
+
339
+ === Environment variables
340
+
341
+ This extension does not require any environment variables.
342
+
343
+ === Configuration options
344
+
345
+ The extension accepts the following options in the Antora playbook.
346
+
347
+ NOTE: Ensure filters are well-defined to minimize unnecessary processing. Avoid overly broad configurations in `data.sets`.
348
+
349
+ - `data.sets` (required): An object defining one or more indexing configurations. Each configuration (or set) accepts the following options:
350
+
351
+ ** `component` (string, required): The Antora component to search for pages.
352
+
353
+ ** `attribute_name` (string, required): The attribute name to assign the generated index data. This allows pages and templates to reference the index.
354
+
355
+ ** `filter` (string, optional): A substring to match within page URLs.
356
+
357
+ ** `env_type` (string, optional): Matches pages with environment-specific attributes (for example, Docker, Kubernetes).
358
+
359
+ ** `output_file` (string, optional): Save the generated index data as a JSON file at the specified path. If not provided, no file is created.
360
+
361
+ === Example configuration
362
+
363
+ Here's an example configuration to enable the generate-index-data-extension:
364
+
365
+ ```yaml
366
+ antora:
367
+ extensions:
368
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/generate-index-data-extension'
369
+ data:
370
+ sets:
371
+ console_ui:
372
+ component: ROOT # Search the ROOT component
373
+ filter: console/ui # Filter pages containing this substring in their URL
374
+ attribute_name: console-ui-index # Save the result in this attribute
375
+ output_file: redpanda-labs/console-ui-index.json # Save data to this file
376
+ docker_labs:
377
+ component: redpanda-labs
378
+ filter: docker-compose
379
+ env_type: Docker
380
+ attribute_name: docker-labs-index
381
+ ```
382
+
383
+ === Use the generated data
384
+
385
+ The index data can be referenced in AsciiDoc pages by specifying the following required attributes:
386
+
387
+ ```asciidoc
388
+ = CONSOLE UI
389
+ :page-index-data: console-ui-index <1>
390
+ :page-role: index-list <2>
391
+ ```
392
+
393
+ <1> The attribute whose data you want to display on the page. This must match an attribute configured in the extension.
394
+ <2> The page role. This role specfies the UI template that renders the data in the `page-index-data` on the page.
395
+
396
+ You can optionally display pages only if they match the component and version of the current Asciidoc page by adding the `:page-match-component-version:` attribute.
397
+
398
+ ```asciidoc
399
+ = CONSOLE UI
400
+ :page-index-data: console-ui-index
401
+ :page-role: index-list
402
+ :page-match-component-version: ''
403
+ ```
404
+
405
+ == Redpanda Connect tag modifier
406
+
407
+ This extension updates the playbook to use the latest release tag for the Redpanda Connect documentation. It ensures that the Redpanda Connect documentation is always pulled from the latest release tag available on GitHub.
408
+
409
+ === Environment variables
410
+
411
+ - `REDPANDA_GITHUB_TOKEN` (optional): A Personal access token (PAT) that has `repo` permissions for the `redpanda-data` GitHub organization.
412
+
413
+ NOTE: If you don't set the environment variable, the latest version of Redpanda Connect may not be fetched. When the environment variable is not set, the extension sends unauthenticated requests to GitHub. Unauthenticated requests may result in hitting the API rate limit and cause GitHub to reject the request. In this case the fallback version is used. This version is defined in the playbook where the extension is registered.
414
+
415
+ === Configuration options
416
+
417
+ There are no configurable options for this extension.
418
+
419
+ === Registration
420
+
421
+ ```yaml
422
+ antora:
423
+ extensions:
424
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/modify-connect-tag-playbook'
425
+ ```
426
+
427
+ == Version fetcher
428
+
429
+ This extension fetches the latest release versions from GitHub.
430
+
431
+ The following attributes are available to all versions of all Antora components:
432
+
433
+ `latest-console-version`: The latest release version of Redpanda Console.
434
+ `latest-connect-version`: The latest release version of Redpanda Connect.
435
+ `redpanda-beta-version`: The latest RC version of Redpanda.
436
+ `redpanda-beta-commit`: The commit hash for the latest RC version of Redpanda.
437
+
438
+ The following attributes are available to the latest version of the `ROOT` component (Redpanda docs):
439
+
440
+ `full-version`: The latest release version of Redpanda.
441
+ `latest-release-commit`: The commit hash for the latest release version of Redpanda.
442
+ `latest-operator-version`: The latest release version of the Redpanda Operator.
443
+ `latest-redpanda-helm-chart-version`: The latest release version of the Redpanda Helm chart.
444
+
445
+ === Environment variables
446
+
447
+ - `REDPANDA_GITHUB_TOKEN` (optional): A Personal access token (PAT) that has `repo` permissions for the `redpanda-data` GitHub organization.
448
+
449
+ NOTE: If you don't set the environment variable, the latest versions may not be fetched. When the environment variable is not set, the extension sends unauthenticated requests to GitHub. Unauthenticated requests may result in hitting the API rate limit and cause GitHub to reject the request.
450
+
451
+ === Registration
452
+
453
+ ```yaml
454
+ antora:
455
+ extensions:
456
+ - '@redpanda-data/docs-extensions-and-macros/extensions/version-fetcher/set-latest-version'
457
+ ```
458
+
459
+ == Validate attributes
460
+
461
+ This extension ensures the consistency and validity of page attributes, focusing on validating page categories against a predefined list of valid categories and subcategories. It automatically adds missing parent categories for any specified subcategories and removes any specified categories that are invalid. Additionally, it processes specific environment attributes, setting corresponding page-level attributes when environment conditions are met.
462
+
463
+ === Environment variables
464
+
465
+ This extension does not require any environment variables.
466
+
467
+ === Configuration options
468
+
469
+ There are no configurable options for this extension. It operates based on site attributes defined in `add-global-attributes.js` to determine valid categories and subcategories.
470
+
471
+ === Registration
472
+
473
+ Register the `validate-attributes` extension in the Antora playbook under the `antora.extensions` key like so:
474
+
475
+ [source,yaml]
476
+ ----
477
+ antora:
478
+ extensions:
479
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/validate-attributes.js'
480
+ ----
481
+
482
+ == Related docs
483
+
484
+ This extension enhances the connectivity between lab exercises and relevant documentation by dynamically identifying and linking related documentation pages and other lab exercises based on shared categories and deployment types.
485
+
486
+ === Environment variables
487
+
488
+ This extension operates without requiring any specific environment variables.
489
+
490
+ === Configuration options
491
+
492
+ This extension does not offer configurable options. It uses the inherent attributes of pages to determine relationships based on `page-categories` and deployment types (`env-kubernetes`, `env-linux`, `env-docker`, `page-cloud`).
493
+
494
+ === Registration
495
+
496
+ To integrate the `related-docs-extension` into your Antora playbook, add it under the `antora.extensions` key as demonstrated below:
497
+
498
+ [source,yaml]
499
+ ----
500
+ antora:
501
+ extensions:
502
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/related-docs-extension.js'
503
+ ----
504
+
505
+ == Related labs
506
+
507
+ This extension enriches documentation pages with links to related lab exercises, facilitating a deeper understanding of the content through practical application. It dynamically assigns related labs to each documentation page based on shared categories and deployment types.
508
+
509
+ === Environment variables
510
+
511
+ This extension does not require any environment variables.
512
+
513
+ === Configuration options
514
+
515
+ The extension operates without explicit configuration options. It automatically processes documentation pages to identify and link related labs based on shared `page-categories` attributes and deployment types (`env-kubernetes`, `env-linux`, `env-docker`, `page-cloud`).
516
+
517
+ === Registration
518
+
519
+ Include the `related-labs-extension` in the Antora playbook under the `antora.extensions` key as follows:
520
+
521
+ [source,yaml]
522
+ ----
523
+ antora:
524
+ extensions:
525
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/related-labs-extension.js'
526
+ ----
527
+
528
+ == Global attributes
529
+
530
+ This extension collects Asciidoc attributes from the https://github.com/redpanda-data/docs-site[`shared` component] or a local YAML file and makes them available to all component versions. Having global attributes is useful for consistent configuration of local and production builds.
531
+
532
+ === Environment variables
533
+
534
+ This extension does not require any environment variables.
535
+
536
+ === Configuration options
537
+
538
+ The extension accepts the following configuration options:
539
+
540
+ attributespath (optional):: Specifies the path to a local YAML file that contains global attributes. If this is provided, the extension will load attributes from this file first. If this path is not provided or no valid attributes are found in the file, the extension will fall back to loading attributes from the `shared` component.
541
+
542
+ === Registration
543
+
544
+ ```yml
545
+ antora:
546
+ extensions:
547
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/add-global-attributes'
548
+ attributespath: './local-attributes.yml'
549
+ ```
550
+
551
+ In this example, the `attributespath` option points to a local YAML file (`./local-attributes.yml`), which contains the global attributes. The extension will load attributes from this file first before falling back to the `shared` component.
552
+
553
+ == Produce redirects (customization of core Antora)
554
+
555
+ This extension replaces the default https://gitlab.com/antora/antora/-/tree/v3.1.x/packages/redirect-producer[`produceRedirects()` function] in Antora to handle redirect loops caused by https://docs.antora.org/antora/latest/page/page-aliases/[page aliases]. Normally, page aliases in Antora are used to resolve outdated links without causing issues. However, with https://docs.antora.org/antora/latest/playbook/urls-html-extension-style/#html-extension-style-key[`indexify`], the same URL may inadvertently be used for both the source and target of a redirect, leading to loops. This problem is https://antora.zulipchat.com/#narrow/stream/282400-users/topic/Redirect.20Loop.20Issue.20with.20Page.20Renaming.20and.20Indexify/near/433691700[recognized as a bug] in core Antora. For example, creating a page alias for `modules/manage/security/authorization.adoc` to point to `modules/manage/security/authorization/index.adoc' can lead to a redirect loop where `manage/security/authorization/` points to `manage/security/authorization/`. Furthermore, omitting the alias would lead to `xref not found` errors because Antora relies on the alias to resolve the old xrefs. This extension is necessary until such behaviors are natively supported or fixed in Antora core.
556
+
557
+ === Environment variables
558
+
559
+ This extension does not require any environment variables.
560
+
561
+ === Configuration options
562
+
563
+ There are no configurable options for this extension.
564
+
565
+ === Registration
566
+
567
+ ```yaml
568
+ antora:
569
+ extensions:
570
+ - '@redpanda-data/docs-extensions-and-macros/extensions/modify-redirects'
571
+ ```
572
+
573
+ == Replace attributes in attachments
574
+
575
+ This extension automates the replacement of AsciiDoc attribute placeholders with their respective values within attachment files, such as CSS, HTML, and YAML.
576
+
577
+ [NOTE]
578
+ ====
579
+ - The `@` character is removed from attribute values to prevent potential issues with CSS or HTML syntax.
580
+ - If the same attribute placeholder is used multiple times within a file, all instances will be replaced with the attribute's value.
581
+ ====
582
+
583
+ === Environment variables
584
+
585
+ This extension does not require any environment variables.
586
+
587
+ === Configuration options
588
+
589
+ The extension accepts the following configuration options in the Antora playbook:
590
+
591
+ data.replacements (required):: An array of replacement configurations. Each configuration can target multiple components and define specific file patterns and custom replacement rules.
592
+
593
+ * `components` (array of strings, required): Lists the names of the Antora components whose attachments should undergo attribute replacement.
594
+
595
+ * `file_patterns` (array of strings, required): Glob patterns specifying which attachment files to process. These patterns determine the files that will undergo attribute replacement based on their paths within the content catalog.
596
+
597
+ * `custom_replacements` (array of objects, optional): Defines custom search-and-replace rules to be applied to the matched files. Each rule consists of:
598
+ ** `search` (string, required): A regular expression pattern to search for within the file content.
599
+ ** `replace` (string, required): The string to replace each match found by the `search` pattern.
600
+
601
+ NOTE: Ensure that `file_patterns` accurately reflect the paths of the attachments you want to process. Overly broad patterns may include unintended files, while overly restrictive patterns might exclude necessary resources.
602
+
603
+ === Registration
604
+
605
+ This is an example of how to register and configure the `replace-attributes-in-attachments` extension in your Antora playbook. This example demonstrates defining multiple replacement configurations, each targeting different components and specifying their own file patterns and custom replacements.
606
+
607
+ ```yaml
608
+ antora:
609
+ extensions:
610
+ - require: './extensions/replace-attributes-in-attachments'
611
+ data:
612
+ replacements:
613
+ - components:
614
+ - 'ROOT'
615
+ - 'redpanda-labs'
616
+ file_patterns:
617
+ - '**/docker-compose.yaml'
618
+ - '**/docker-compose.yml'
619
+ custom_replacements:
620
+ - search: ''\\$\\{CONFIG_FILE:[^}]*\\}''
621
+ replace: 'console.yaml'
622
+ - components:
623
+ - 'API'
624
+ file_patterns:
625
+ - '**/api-docs/**/resources/**'
626
+ custom_replacements:
627
+ - search: '\\$\\{API_ENDPOINT:[^}]*\\}'
628
+ replace: 'https://api.example.com'
629
+ ```
630
+
631
+ == Aggregate terms
632
+
633
+ This extension aggregates all term pages from the https://github.com/redpanda-data/docs-site[`shared` component] and does the following:
634
+
635
+ - Makes all `term-name`, `hover-text`, and `link` attributes available to the `glossterm` macro.
636
+ - Looks for glossary pages named `reference:glossary.adoc` in all versions of all components and appends the contents of each term file to the glossary in alphabetical order.
637
+ - If a glossary page is found, sets the `glossary-page` attribute of the `glossterm` macro to `reference:glossary.adoc` so that terms can be linked to the glossary page.
638
+
639
+ === Environment variables
640
+
641
+ This extension does not require any environment variables.
642
+
643
+ === Configuration options
644
+
645
+ The extension accepts the following configuration options:
646
+
647
+ termspath (optional):: Specifies the path to a local directory containing term files (in `.adoc` format). If this path is provided, the extension will attempt to load terms from this directory first. If this path is not provided or no valid terms are found in the specified directory, the extension will fall back to loading terms from the `shared` component.
648
+
649
+ Term files should follow the following structure:
650
+
651
+ ```asciidoc
652
+ :category: Documentation
653
+ :hover-text: This is a description of the term.
654
+ :link: https://example.com
655
+
656
+ == Term Title
657
+
658
+ This is the detailed description of the term.
659
+ ```
660
+
661
+ === Registration
662
+
663
+ ```yml
664
+ antora:
665
+ extensions:
666
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/aggregate-terms'
667
+ termspath: './local-terms/'
668
+ ```
669
+
670
+ In this example, the `termspath` option points to a local directory (./local-terms/), where the term files are stored. The extension will load terms from this directory first before falling back to the `shared` component.
671
+
672
+ == Unlisted pages
673
+
674
+ This extension identifies and logs any pages that aren't listed in the navigation (nav) file of each version of each component. It then optionally adds these unlisted pages to the end of the navigation tree under a configurable heading.
675
+
676
+ IMPORTANT: By default, this extension excludes components named 'api'. This behavior is hardcoded and cannot be changed in the configuration.
677
+
678
+ === Environment variables
679
+
680
+ This extension does not require any environment variables.
681
+
682
+ === Configuration options
683
+
684
+ This extension accepts the following configuration options:
685
+
686
+ addToNavigation (optional)::
687
+ Whether to add unlisted pages to the navigation. The default is `false` (unlisted pages are not added).
688
+
689
+ unlistedPagesHeading (optional)::
690
+ The heading under which to list the unlisted pages in the navigation. The default is 'Unlisted Pages'.
691
+
692
+ === Registration
693
+
694
+ ```yaml
695
+ antora:
696
+ extensions:
697
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/unlisted-pages'
698
+ addToNavigation: true
699
+ unlistedPagesHeading: 'Additional Resources'
700
+ ```
701
+
702
+ == Process context switcher
703
+
704
+ This extension processes the `page-context-switcher` attribute to enable cross-version navigation widgets in documentation pages. It automatically replaces "current" references with full resource IDs and injects the context switcher configuration to all referenced target pages, ensuring bidirectional navigation works correctly.
705
+
706
+ The extension finds pages with the `page-context-switcher` attribute, parses the JSON configuration, and:
707
+
708
+ 1. Replaces any "current" values with the full resource ID of the current page
709
+ 2. Finds all target pages referenced in the switcher configuration
710
+ 3. Injects the same context switcher attribute to target pages (with appropriate resource ID mappings)
711
+ 4. Builds resource IDs in the format: `version@component:module:relative-path`
712
+
713
+ This enables UI components to render version switchers that work across different versions of the same content.
714
+
715
+ === Environment variables
716
+
717
+ This extension does not require any environment variables.
718
+
719
+ === Configuration options
720
+
721
+ This extension does not require any configuration options.
722
+
723
+ === Registration
724
+
725
+ ```yaml
726
+ antora:
727
+ extensions:
728
+ - require: '@redpanda-data/docs-extensions-and-macros/extensions/process-context-switcher'
729
+ ```
730
+
731
+ === Usage
732
+
733
+ Add the `page-context-switcher` attribute to any page where you want cross-version navigation:
734
+
735
+ ```asciidoc
736
+ :page-context-switcher: [{"name": "Version 2.x", "to": "24.3@ROOT:console:config/security/authentication.adoc" },{"name": "Version 3.x", "to": "current" }]
737
+ ```
738
+
739
+ === Processed output
740
+
741
+ After processing, the "current" reference is replaced with the full resource ID:
742
+
743
+ ```json
744
+ [
745
+ {"name": "Version 2.x", "to": "24.3@ROOT:console:config/security/authentication.adoc"},
746
+ {"name": "Version 3.x", "to": "current@ROOT:console:config/security/authentication.adoc"}
747
+ ]
748
+ ```
749
+
750
+ The target page (`24.3@ROOT:console:config/security/authentication.adoc`) will also receive the same context switcher configuration with appropriate resource ID mappings.
751
+
752
+ === UI integration
753
+
754
+ The processed attribute can be used in Handlebars templates:
755
+
756
+ ```html
757
+ <div class="context-switcher">
758
+ {{#each (obj page.attributes.page-context-switcher)}}
759
+ <a
760
+ id="{{{this.name}}}"
761
+ href="{{{relativize (resolve-resource this.to)}}}"
762
+ class="context-link {{#if (eq @root.page.url (resolve-resource this.to))}}active{{/if}}"
763
+ >
764
+ <button type="button">{{{this.name}}}</button>
765
+ </a>
766
+ {{/each}}
767
+ </div>
768
+ ```