@redpanda-data/docs-extensions-and-macros 5.37.1 → 5.37.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.
|
@@ -32,7 +32,9 @@
|
|
|
32
32
|
|
|
33
33
|
const loadAsciiDoc = require('@antora/asciidoc-loader')
|
|
34
34
|
const bigIntJson = require('../cli-utils/big-int-json')
|
|
35
|
-
|
|
35
|
+
// compareTags is the one set-available-attachment-versions.js uses to pick the
|
|
36
|
+
// tooltip dataset, so the build-time choice and the runtime fetch cannot disagree.
|
|
37
|
+
const { buildPageIndex, propertyAnchor, compareTags } = require('../macros/prop')
|
|
36
38
|
const { raiseListenerLimit } = require('./util/raise-listener-limit')
|
|
37
39
|
|
|
38
40
|
const PROPERTIES_JSON_RX = /^redpanda-properties-(v\d+\.\d+\.\d+(?:-[\w.]+)?)\.json$/
|
|
@@ -57,7 +59,7 @@ module.exports.register = function () {
|
|
|
57
59
|
// without that every <<anchor>> silently degraded to plain text.
|
|
58
60
|
const anchorIndexes = new Map()
|
|
59
61
|
this.once('contentClassified', ({ contentCatalog }) => {
|
|
60
|
-
for (const attachment of
|
|
62
|
+
for (const attachment of newestPropertyAttachments(contentCatalog)) {
|
|
61
63
|
const properties = readProperties(attachment, logger)
|
|
62
64
|
if (!properties) continue
|
|
63
65
|
const key = `${attachment.src.component}@${attachment.src.version || ''}`
|
|
@@ -72,7 +74,7 @@ module.exports.register = function () {
|
|
|
72
74
|
// class="xref unresolved" while the same xref resolved fine on a real page.
|
|
73
75
|
// Attachments are still published after this event.
|
|
74
76
|
this.once('documentsConverted', ({ contentCatalog, siteAsciiDocConfig }) => {
|
|
75
|
-
const attachments =
|
|
77
|
+
const attachments = newestPropertyAttachments(contentCatalog)
|
|
76
78
|
if (!attachments.length) return
|
|
77
79
|
|
|
78
80
|
for (const attachment of attachments) {
|
|
@@ -135,13 +137,13 @@ module.exports.register = function () {
|
|
|
135
137
|
logger.info(`${where}: rendered ${rendered} property descriptions to HTML${failed ? `, ${failed} failed` : ''}`)
|
|
136
138
|
if (unresolved.size) {
|
|
137
139
|
logger.warn(
|
|
138
|
-
`${where}: ${unresolved.size} xref target(s) in property descriptions could not be resolved, so they stay as raw macros in the published attachment: ` +
|
|
140
|
+
`${where} (${basename(attachment)}): ${unresolved.size} xref target(s) in property descriptions could not be resolved, so they stay as raw macros in the published attachment: ` +
|
|
139
141
|
`${[...unresolved].sort().join(', ')}.`
|
|
140
142
|
)
|
|
141
143
|
}
|
|
142
144
|
if (brokenAnchors.size) {
|
|
143
145
|
logger.warn(
|
|
144
|
-
`${where}: ${brokenAnchors.size} <<anchor>> reference(s) in property descriptions name no documented property, so they render as plain text: ` +
|
|
146
|
+
`${where} (${basename(attachment)}): ${brokenAnchors.size} <<anchor>> reference(s) in property descriptions name no documented property, so they render as plain text: ` +
|
|
145
147
|
`${[...brokenAnchors].sort().join(', ')}. Property anchors replace dots with hyphens, so redpanda.storage.mode is <<redpanda-storage-mode>>. ` +
|
|
146
148
|
'Fix them in the description or in docs-data/property-overrides.json.'
|
|
147
149
|
)
|
|
@@ -160,6 +162,36 @@ function propertyAttachments (contentCatalog) {
|
|
|
160
162
|
)
|
|
161
163
|
}
|
|
162
164
|
|
|
165
|
+
function tagOf (file) {
|
|
166
|
+
return basename(file).match(PROPERTIES_JSON_RX)[1]
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* The newest property dataset per component version, and only that one.
|
|
172
|
+
*
|
|
173
|
+
* A branch can ship more than one: doc-tools retains the 2 newest property
|
|
174
|
+
* JSONs on purpose, because the next generation run needs the older one as its
|
|
175
|
+
* --diff baseline. Only the newest is ever read as a dataset -- the docs UI
|
|
176
|
+
* resolves tooltips against available-properties-tag, which
|
|
177
|
+
* set-available-attachment-versions sets to the newest -- so rendering the
|
|
178
|
+
* older one is not just wasted work. This extension rewrites
|
|
179
|
+
* entry.description to resolve xrefs and then replaces the attachment
|
|
180
|
+
* contents, so converting a baseline would make the next diff report a
|
|
181
|
+
* description change for every property in it, and every dead <<anchor>> in a
|
|
182
|
+
* superseded dataset would be reported a second time against a file nobody
|
|
183
|
+
* publishes.
|
|
184
|
+
*/
|
|
185
|
+
function newestPropertyAttachments (contentCatalog) {
|
|
186
|
+
const newest = new Map()
|
|
187
|
+
for (const file of propertyAttachments(contentCatalog)) {
|
|
188
|
+
const key = `${file.src.component}@${file.src.version || ''}`
|
|
189
|
+
const held = newest.get(key)
|
|
190
|
+
if (!held || compareTags(tagOf(file), tagOf(held)) > 0) newest.set(key, file)
|
|
191
|
+
}
|
|
192
|
+
return [...newest.values()]
|
|
193
|
+
}
|
|
194
|
+
|
|
163
195
|
/**
|
|
164
196
|
* Parse one dataset, or report why it is unusable and return undefined. Left
|
|
165
197
|
* as-is on failure: the prop macro reports an unusable dataset with the detail,
|