@redpanda-data/docs-extensions-and-macros 3.0.0 → 3.0.2

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/README.adoc CHANGED
@@ -115,7 +115,7 @@ This extension replaces AsciiDoc attribute placeholders with their respective va
115
115
 
116
116
  [IMPORTANT]
117
117
  ====
118
- - By default, this extension processes attachments for the `ROOT` (redpanda) component only. This behavior is hardcoded and cannot be changed in the configuration.
118
+ - This extension processes attachments only if the component version includes the attribute `replace-attributes-in-attachments: true`.
119
119
  - The `@` character is removed from attribute values to prevent potential issues with CSS or HTML syntax.
120
120
  - If the same attribute placeholder is used multiple times within a file, all instances will be replaced with the attribute's value.
121
121
  ====
@@ -133,13 +133,8 @@ antora:
133
133
  This extension aggregates all term pages from the {url-playbook}[`shared` component] and does the following:
134
134
 
135
135
  - Makes all `term-name` and `hover-text` attributes available to the <<glossterm-macro,`glossterm` macro>>.
136
- - Looks for glossary pages named `reference:glossary.adoc` in all versions of the Redpanda docs and appends the contents of each term file to the glossary in alphabetical order.
137
- - If a glossary page is found, sets the `glossary-page` attribute of the `glossterm` macro to `reference:glossary.adoc`.
138
-
139
- [IMPORTANT]
140
- ====
141
- By default, this extension processes glossary pages for the `ROOT` (redpanda) component only. This behavior is hardcoded and cannot be changed in the configuration.
142
- ====
136
+ - 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.
137
+ - If a glossary page is found, sets the `glossary-page` attribute of the <<glossterm, `glossterm` macro>> to `reference:glossary.adoc`.
143
138
 
144
139
  ==== Registration example
145
140
 
@@ -33,10 +33,12 @@ module.exports.register = function ({ config }) {
33
33
  .on('contentClassified', ({ siteCatalog, contentCatalog }) => {
34
34
  const components = contentCatalog.getComponents()
35
35
  try {
36
- components.forEach(({asciidoc}) => {
37
- asciidoc.attributes = _.merge(asciidoc.attributes, siteCatalog.attributeFile);
36
+ components.forEach(({versions}) => {
37
+ versions.forEach(({asciidoc}) => {
38
+ asciidoc.attributes = _.merge(asciidoc.attributes, siteCatalog.attributeFile);
39
+ })
38
40
  });
39
- console.log(chalk.green('Merged global attributes into each component.'));
41
+ console.log(chalk.green('Merged global attributes into each component version.'));
40
42
  } catch (error) {
41
43
  logger.error(`Error merging attributes: ${error.message}`);
42
44
  }
@@ -32,8 +32,7 @@ module.exports.register = function ({ config }) {
32
32
  try {
33
33
  for (const { versions } of components) {
34
34
  for (const { name: component, version, asciidoc, title } of versions) {
35
- // TODO: will need a better way to filter when we have more content components
36
- if (component !== 'ROOT') continue;
35
+ if (component == 'shared') continue;
37
36
  const glossaryPage = contentCatalog.resolvePage(`${version?version +'@':''}${component}:reference:glossary.adoc`);
38
37
  if (glossaryPage) {
39
38
  asciidoc.attributes['glossary-page'] = 'reference:glossary.adoc'
@@ -4,22 +4,17 @@ module.exports.register = function ({ config }) {
4
4
 
5
5
  const sanitizeAttributeValue = (value) => String(value).replace("@", "");
6
6
 
7
- this.on('documentsConverted', ({playbook, contentCatalog}) => {
7
+ this.on('documentsConverted', ({contentCatalog}) => {
8
8
  for (const { versions } of contentCatalog.getComponents()) {
9
- for (const { name: component, version } of versions) {
10
- // TODO: will need a better way to filter when we have more content components
11
- if (component !== 'ROOT') continue;
9
+ for (const { name: component, version, asciidoc } of versions) {
12
10
  const attachments = contentCatalog.findBy({ component, version, family });
13
11
  for (const attachment of attachments) {
14
12
  let contentString = String.fromCharCode(...attachment['_contents']);
15
- const attributes = attachment.src.origin.descriptor.asciidoc.attributes;
16
- const mergedAttributes = {
17
- ...playbook.asciidoc.attributes,
18
- ...attributes
19
- };
20
- for (const key in mergedAttributes) {
13
+ if (!asciidoc.attributes) continue
14
+ if (!asciidoc.attributes.hasOwnProperty('replace-attributes-in-attachments')) continue;
15
+ for (const key in asciidoc.attributes) {
21
16
  const placeholder = "{" + key + "}";
22
- const sanitizedValue = sanitizeAttributeValue(mergedAttributes[key]);
17
+ const sanitizedValue = sanitizeAttributeValue(asciidoc.attributes[key]);
23
18
  contentString = contentString.replace(new RegExp(placeholder, 'g'), sanitizedValue);
24
19
  }
25
20
  attachment['_contents'] = Buffer.from(contentString, "utf-8");
@@ -18,6 +18,10 @@ module.exports.register = function ({ config }) {
18
18
  .on('playbookBuilt', async ({ playbook }) => {
19
19
  try {
20
20
  const LatestConsoleVersion = await GetLatestConsoleVersion();
21
+ if (!LatestConsoleVersion) {
22
+ logger.warn(`Failed to get latest Console version from GitHub`)
23
+ return
24
+ }
21
25
  if (!playbook.asciidoc) {
22
26
  playbook.asciidoc = {};
23
27
  }
@@ -37,7 +41,10 @@ module.exports.register = function ({ config }) {
37
41
  const components = await contentCatalog.getComponents();
38
42
  for (let i = 0; i < components.length; i++) {
39
43
  let component = components[i];
40
- if (LatestRedpandaVersion.length !== 2) logger.warn('Could not find the latest Redpanda versions - using defaults');
44
+ if (LatestRedpandaVersion.length !== 2 || !LatestRedpandaVersion[0]) {
45
+ logger.warn('Failed to get the latest Redpanda versions - using defaults');
46
+ return
47
+ }
41
48
  if (component.name === 'ROOT') {
42
49
 
43
50
  if (!component.latest.asciidoc) {
@@ -115,7 +115,7 @@ module.exports.register = function (registry, config = {}) {
115
115
  const attrs = glossaryTermRole ? { role: glossaryTermRole } : {}
116
116
  var inline;
117
117
  const termExistsInContext = context.gloss.some((candidate) => candidate.term === term);
118
- if (termExistsInContext && links) {
118
+ if ((termExistsInContext && links) || (links && customLink)) {
119
119
  inline = customLink
120
120
  ? self.createInline(parent, 'anchor', target, { type: 'link', target: customLink, attributes: attrs })
121
121
  : self.createInline(parent, 'anchor', target, { type: 'xref', target: `${glossaryPage}#${termId(term)}`, reftext: target, attributes: attrs })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redpanda-data/docs-extensions-and-macros",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Antora extensions and macros developed for Redpanda documentation.",
5
5
  "keywords": [
6
6
  "antora",
@@ -12,6 +12,10 @@
12
12
  "author": {
13
13
  "name": "Redpanda Docs Team"
14
14
  },
15
+ "scripts": {
16
+ "build": "antora --to-dir docs --fetch local-antora-playbook.yml",
17
+ "serve": "wds --node-resolve --open preview/test.html --watch --root-dir docs"
18
+ },
15
19
  "contributors": [
16
20
  {
17
21
  "name": "JakeSCahill",
@@ -41,7 +45,6 @@
41
45
  "url": "git+https://github.com/redpanda-data/docs-extensions-and-macros"
42
46
  },
43
47
  "dependencies": {
44
- "@antora/site-generator": "3.1.2",
45
48
  "@octokit/plugin-retry": "^4.1.3",
46
49
  "@octokit/rest": "^19.0.7",
47
50
  "algoliasearch": "^4.17.0",
@@ -52,5 +55,10 @@
52
55
  "js-yaml": "^4.1.0",
53
56
  "lodash": "^4.17.21",
54
57
  "node-html-parser": "5.4.2-0"
58
+ },
59
+ "devDependencies": {
60
+ "@antora/cli": "3.1.4",
61
+ "@antora/site-generator": "3.1.4",
62
+ "@web/dev-server": "^0.2.5"
55
63
  }
56
64
  }