- Prerequisites
- Antora Extensions
- Add Bloblang samples to pages
- Add pages to root
- Algolia indexer
- Component category aggregator
- Redpanda Connect tag modifier
- Version fetcher
- Validate attributes
- Related docs
- Related labs
- Global attributes
- Produce redirects (customization of core Antora)
- Replace attributes in attachments
- Aggregate terms
- Unlisted pages
- Asciidoc Extensions
- Macros
- Development quickstart
This library provides Antora extensions and Asciidoc macros developed for Redpanda documentation.
To use this library, you must have Node.js 16 or higher installed on your machine.
node --version
If this command fails with an error, you don’t have Node.js installed.
When you have Node.js installed, use the following command to install the antora-extensions-and-macros
package in your project:
npm i @redpanda-data/docs-extensions-and-macros
To use the development version, refer to the Development Quickstart.
This section documents the Antora extensions provided by this library and how to configure them.
❗
|
Ensure you register each extension under the antora.extensions key in the playbook, not the asciidoc.extensions key.
|
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.
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.
To enable the extension, add it to your Antora playbook under the antora.extensions
key. No additional configuration is required.
antora:
extensions:
- require: '@redpanda-data/docs-extensions-and-macros/extensions/collect-bloblang-samples'
The following YAML file is an example of how to define a Bloblang sample:
title: Hello world
input: |
{
"message": "hello world"
}
mapping: |
root.message = this.message.uppercase()
The processed examples are added as JSON to the page-bloblang-samples
attribute. For example:
{
"hello-world.yaml": {
"title": "Hello world",
"input": "{\n \"message\": \"hello world\"\n}\n",
"mapping": "root.message = this.message.uppercase()\n"
},
"array-processing.yaml": {
"title": "Array processing",
"input": "{\n \"numbers\": [1, 2, 3, 4, 5]\n}\n",
"mapping": "root.even_numbers = this.numbers.filter(n -> n % 2 == 0)"
}
}
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.
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.
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.
antora:
extensions:
- require: '@redpanda-data/docs-extensions-and-macros/extensions/add-pages-to-root'
files:
- home:ROOT:attachment$custom-file.txt
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
.
📎
|
Only pages that include an <article> element with the doc class are indexed.
|
-
ALGOLIA_ADMIN_API_KEY
(required) -
ALGOLIA_APP_ID
(required) -
ALGOLIA_INDEX_NAME
(required)
The extension accepts the following configuration options:
- excludes (optional)
-
Any elements, classes, or IDs that you want to exclude from the index.
- index-latest-only (optional)
-
Whether to index all versions or just the latest version of a component.
This extension maps Redpanda Connect component data into a structured format:
-
Maps original component names to common names.
-
Populates
connectCategoriesData
andflatComponentsData
attributes. -
Skips deprecated components.
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.
-
REDPANDA_GITHUB_TOKEN
(optional): A Personal access token (PAT) that hasrepo
permissions for theredpanda-data
GitHub organization.
📎
|
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. |
This extension fetches the latest release versions from GitHub.
The following attributes are available to all versions of all Antora components:
latest-console-version
: The latest release version of Redpanda Console.
latest-connect-version
: The latest release version of Redpanda Connect.
redpanda-beta-version
: The latest RC version of Redpanda.
redpanda-beta-commit
: The commit hash for the latest RC version of Redpanda.
The following attributes are available to the latest version of the ROOT
component (Redpanda docs):
full-version
: The latest release version of Redpanda.
latest-release-commit
: The commit hash for the latest release version of Redpanda.
latest-operator-version
: The latest release version of the Redpanda Operator.
latest-redpanda-helm-chart-version
: The latest release version of the Redpanda Helm chart.
-
REDPANDA_GITHUB_TOKEN
(optional): A Personal access token (PAT) that hasrepo
permissions for theredpanda-data
GitHub organization.
📎
|
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. |
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.
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.
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.
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
).
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.
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
).
This extension collects Asciidoc attributes from the 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.
The extension accepts the following configuration options:
- 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.
antora:
extensions:
- require: '@redpanda-data/docs-extensions-and-macros/extensions/add-global-attributes'
attributespath: './local-attributes.yml'
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.
This extension replaces the default produceRedirects()
function in Antora to handle redirect loops caused by page aliases. Normally, page aliases in Antora are used to resolve outdated links without causing issues. However, with indexify
, the same URL may inadvertently be used for both the source and target of a redirect, leading to loops. This problem is 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.
This extension replaces AsciiDoc attribute placeholders with their respective values in attachment files, such as CSS, HTML, and YAML.
❗
|
|
This extension aggregates all term pages from the shared
component and does the following:
-
Makes all
term-name
,hover-text
, andlink
attributes available to theglossterm
macro. -
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. -
If a glossary page is found, sets the
glossary-page
attribute of theglossterm
macro toreference:glossary.adoc
so that terms can be linked to the glossary page.
The extension accepts the following configuration options:
- 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 theshared
component.
Term files should follow the following structure:
:category: Documentation
:hover-text: This is a description of the term.
:link: https://example.com
== Term Title
This is the detailed description of the term.
antora:
extensions:
- require: '@redpanda-data/docs-extensions-and-macros/extensions/aggregate-terms'
termspath: './local-terms/'
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.
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.
❗
|
By default, this extension excludes components named 'api'. This behavior is hardcoded and cannot be changed in the configuration. |
This extension accepts the following configuration options:
- addToNavigation (optional)
-
Whether to add unlisted pages to the navigation. The default is
false
(unlisted pages are not added). - unlistedPagesHeading (optional)
-
The heading under which to list the unlisted pages in the navigation. The default is 'Unlisted Pages'.
This section documents the Asciidoc extensions that are provided by this library and how to configure them.
❗
|
Be sure to register each extension under the asciidoc.extensions key in the playbook, not the antora.extensions key.
|
This section documents the Asciidoc macros that are provided by this library and how to configure them.
❗
|
Be sure to register each extension under the asciidoc.extensions key in the playbook, not the antora.extensions key.
|
This inline macro is used to generate a reference to a configuration value in the Redpanda documentation. The macro’s parameters allow for control over the generated reference’s format and the type of output produced.
The config_ref
macro is used in an AsciiDoc document as follows:
config_ref:configRef,isLink,path[]
The config_ref
macro takes three parameters:
- configRef
-
This is the configuration reference, which is also used to generate the anchor link if
isLink
istrue
. - isLink
-
Whether the output should be a link. If
isLink
is set totrue
, the output will be a cross-reference (xref) to the relevant configuration value. - path
-
This is the path to the document where the configuration value is defined. This parameter is used to to generate the link if
isLink
istrue
.
❗
|
The path must be the name of a document at the root of the reference module.
|
📎
|
The config_ref macro is environment-aware. It checks if the document it is being used in is part of a Kubernetes environment by checking if the env-kubernetes attribute is set in the document’s attributes. Depending on this check, it either prepends storage.tieredConfig. to the configRef or just uses the configRef as is.
|
For example:
config_ref:example_config,true,tunable-properties[]
The glossterm
inline macro provides a way to define and reference glossary terms in your AsciiDoc documents.
📎
|
This macro is a customized version of asciidoctor-glossary .
|
Use the glossterm
inline macro to reference a term within the text of the document:
glossterm:my term[myDefinition]
It takes two parameters:
- term
-
The term to be defined.
- definition (optional)
-
The definition of the term. If the term is defined in the
shared
component or thelocal-terms
object of theantora.yml
file, you can omit the definition as it will always be replaced by those definitions.
- glossary-log-terms (optional)
-
Whether to log a textual representation of a definition list item to the console.
- glossary-term-role (optional)
-
Role to assign each term. By default, glossary terms are assigned the
glossary-term
role, which gives them the classglossary-term
in generated html. - glossary-links (optional)
-
Whether to generate links to glossary entries. By default, links to the glossary entries are generated from the glossary terms. To avoid this, set the attribute to
false
as either asciidoctor configuration or a header attribute. - glossary-page (optional)
-
Target page for glossary links. By default, links are generated to the same page as the glossary term. To specify the target page, set this attribute to the resource ID of a page where the
glossary
block macro is used. - glossary-tooltip (optional)
-
Whether to enable tooltips for the defined terms. Valid values are:
-
title: This uses the browser built-in
title
attribute to display the definition. -
true: This inserts the definition as the value of the attribute
data-glossary-tooltip
. -
data-<attribute-name>: This inserts the definition as the value of the supplied attribute name, which must start with
data
.
-
The last two options are intended to support js/css tooltip solutions such as tippy.js.
This is an inline macro to create links to a Helm values.yaml
file on ArtifactHub.
In an AsciiDoc document, use the helm_ref
macro as follows:
helm_ref:<helmRef>[]
Where <helmRef>
is the Helm configuration value you want to reference in the values.yaml
file.
For example:
Given a Helm reference value of myConfigValue
, you would use the macro like this:
helm_ref:myConfigValue[]
This will generate the following output:
For default values and documentation for configuration options, see the https://artifacthub.io/packages/helm/redpanda-data/redpanda?modal=values&path=myConfigValue[values.yaml] file.
If you do not specify a Helm reference value, the macro generates a link without specifying a path.
This macro generates a tabbed interface to display Redpanda Connect components by category.
The categories are fetched from the connectCategoriesData
that’s generated in the Component category aggregator extension.
This macro generates a searchable table of all Redpanda Connect components with filters for support and type.
The types are fetched from the flatComponentsData
that’s generated in the Component category aggregator extension.
This macro generates a dropdown of other supported types for a particular component, allowing users to switch between different types.
The types are fetched from the flatComponentsData
that’s generated in the Component category aggregator extension.
This section provides information on how to develop this project.
To build this project, you need the following software installed on your computer:
Make sure you have git installed.
git --version
If not, download and install the git package for your system.
Clone the project using git:
git clone https://github.com/redpanda-data/docs-extensions-and-macros
Change into the project directory and stay in this directory when running all subsequent commands.
Use npm to install the project’s dependencies inside the project. In your terminal, run the following command:
npm ci
This command installs the dependencies listed in package-lock.json
into the node_modules/
directory inside the project.
This directory should not be committed to the source control repository.