@redpanda-data/docs-extensions-and-macros 5.3.3 → 5.3.4
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/package.json
CHANGED
|
@@ -501,6 +501,52 @@ function updateWhatsNew ({ dataDir, oldVersion, newVersion, binaryAnalysis }) {
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
|
|
504
|
+
/**
|
|
505
|
+
* Derive the fragment anchor for a connector field heading.
|
|
506
|
+
*
|
|
507
|
+
* Field docs render each field as a section heading (for example,
|
|
508
|
+
* `=== \`batching.byte_size\``), and the docs site builds section IDs with
|
|
509
|
+
* `idprefix: ''` and `idseparator: '-'` (set in the shared global-attributes
|
|
510
|
+
* component loaded by the Antora playbook). Under those settings Asciidoctor
|
|
511
|
+
* derives IDs by downcasing the heading text, dropping characters that are
|
|
512
|
+
* not word characters, hyphens, dots, or spaces (so `[]` array markers are
|
|
513
|
+
* discarded), converting runs of dots and spaces to a single `-`, and
|
|
514
|
+
* trimming any leading or trailing separator.
|
|
515
|
+
*
|
|
516
|
+
* Examples of rendered IDs this must match:
|
|
517
|
+
* - `checkpoint_limit` -> `checkpoint_limit`
|
|
518
|
+
* - `batching.byte_size` -> `batching-byte_size`
|
|
519
|
+
* - `batching.processors[]` -> `batching-processors`
|
|
520
|
+
* - `sasl[].aws.credentials.from_ec2_role` -> `sasl-aws-credentials-from_ec2_role`
|
|
521
|
+
*
|
|
522
|
+
* Collision caveat: Asciidoctor de-duplicates repeated IDs on a page by
|
|
523
|
+
* appending `-2`, `-3`, ... to later occurrences. If two fields on one page
|
|
524
|
+
* normalize to the same anchor, the generated link resolves to the first
|
|
525
|
+
* heading and the second gets the suffixed ID. This helper cannot detect
|
|
526
|
+
* that, so a wrong-but-plausible link on a page with near-duplicate field
|
|
527
|
+
* names should be checked against this behavior first.
|
|
528
|
+
*
|
|
529
|
+
* @param {string} fieldName - Field name as it appears in the connector data
|
|
530
|
+
* @returns {string} Fragment anchor matching the rendered heading ID
|
|
531
|
+
*/
|
|
532
|
+
function fieldAnchor (fieldName) {
|
|
533
|
+
const anchor = String(fieldName)
|
|
534
|
+
.toLowerCase()
|
|
535
|
+
// Characters that are invalid in section IDs (for example, `[` and `]`
|
|
536
|
+
// array markers) are removed outright, matching Asciidoctor's
|
|
537
|
+
// InvalidSectionIdCharsRx. The dots still supply the separators, so
|
|
538
|
+
// every `[]` case stays correct (`sasl[].aws` -> `sasl-aws`).
|
|
539
|
+
.replace(/[^ \w\-.]+/g, '')
|
|
540
|
+
// idseparator '-' replaces runs of spaces and dots with a single hyphen.
|
|
541
|
+
.replace(/[ .]+/g, '-')
|
|
542
|
+
// idprefix '' means no leading separator, and Asciidoctor chomps a
|
|
543
|
+
// trailing separator.
|
|
544
|
+
.replace(/^-+/, '')
|
|
545
|
+
.replace(/-+$/, '')
|
|
546
|
+
// A name that normalizes to nothing would emit a malformed `#[...]` xref.
|
|
547
|
+
return anchor || String(fieldName)
|
|
548
|
+
}
|
|
549
|
+
|
|
504
550
|
/**
|
|
505
551
|
* Build a fields table for whats-new.adoc
|
|
506
552
|
* @param {Array} fields - Field data
|
|
@@ -541,7 +587,7 @@ function buildFieldsTable (fields, capFn) {
|
|
|
541
587
|
|
|
542
588
|
componentList += `*${typeLabel}:*\n\n`
|
|
543
589
|
names.forEach(name => {
|
|
544
|
-
componentList += `* xref:components:${type}/${name}.adoc#${fieldName}[${name}]\n`
|
|
590
|
+
componentList += `* xref:components:${type}/${name}.adoc#${fieldAnchor(fieldName)}[${name}]\n`
|
|
545
591
|
})
|
|
546
592
|
}
|
|
547
593
|
|
|
@@ -611,7 +657,7 @@ function buildChangedDefaultsTable (changedDefaults, capFn) {
|
|
|
611
657
|
|
|
612
658
|
componentList += `*${typeLabel}:*\n\n`
|
|
613
659
|
names.forEach(name => {
|
|
614
|
-
componentList += `* xref:components:${type}/${name}.adoc#${info.field}[${name}]\n`
|
|
660
|
+
componentList += `* xref:components:${type}/${name}.adoc#${fieldAnchor(info.field)}[${name}]\n`
|
|
615
661
|
})
|
|
616
662
|
}
|
|
617
663
|
|
|
@@ -2014,5 +2060,8 @@ module.exports = {
|
|
|
2014
2060
|
updateWhatsNew,
|
|
2015
2061
|
capToTwoSentences,
|
|
2016
2062
|
augmentConnectorData,
|
|
2017
|
-
buildCleanOssData
|
|
2063
|
+
buildCleanOssData,
|
|
2064
|
+
fieldAnchor,
|
|
2065
|
+
buildFieldsTable,
|
|
2066
|
+
buildChangedDefaultsTable
|
|
2018
2067
|
}
|