@baiyibai-antora/extensions 1.7.0 → 1.8.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.
package/CHANGELOG.adoc CHANGED
@@ -3,6 +3,12 @@
3
3
 
4
4
  All notable changes to this project will be documented in this file.
5
5
 
6
+ == [1.8.0] - 2026-08-17
7
+
8
+ === Added
9
+
10
+ * autoterm: generates a Terminology section and a linked Index from AsciiDoc index term markup, replacing the asciidoctor-autoterm gem and its stub-page extension. A component participates by including `partial$generated-terminology.adoc` or `partial$generated-index.adoc` on a page; definitions merge from the shared `terminology_file` partial with a component's `terminology-local.adoc` rows winning. The PDF index renders through `:assembly-style: index` and stock Asciidoctor PDF; the HTML and Confluence index links to the pages using each term
11
+
6
12
  == [1.7.0] - 2026-08-17
7
13
 
8
14
  === Added
@@ -0,0 +1,210 @@
1
+ /**
2
+ * @baiyibai-antora/extensions - autoterm
3
+ *
4
+ * Scans the Antora content catalog for AsciiDoc index term markup and injects
5
+ * two generated AsciiDoc partials into each participating component-version:
6
+ *
7
+ * modules/ROOT/partials/generated-terminology.adoc
8
+ * modules/ROOT/partials/generated-index.adoc
9
+ *
10
+ * A component participates by containing a page that includes the partial:
11
+ *
12
+ * include::partial$generated-terminology.adoc[]
13
+ * include::partial$generated-index.adoc[]
14
+ *
15
+ * The including page's position in nav.adoc controls where the section
16
+ * appears. The terminology page carries :!sectnums: to render unnumbered.
17
+ * The index page carries :assembly-style: index so the Antora Assembler
18
+ * preserves the [index] section and stock asciidoctor-pdf renders the
19
+ * page-numbered index; the generated index partial holds the web-linked
20
+ * index guarded by ifndef::loader-assembler[] so it renders only outside
21
+ * the PDF build.
22
+ *
23
+ * Definitions come from a shared table (the autoterm-data component's
24
+ * partial) optionally overridden per component by a local partial named
25
+ * trademark-local-style: modules/ROOT/partials/terminology-local.adoc.
26
+ * Local rows replace shared rows for the same term.
27
+ *
28
+ * Configuration in antora-playbook.yml:
29
+ *
30
+ * antora:
31
+ * extensions:
32
+ * - require: '@baiyibai-antora/extensions/autoterm'
33
+ * autoterm:
34
+ * enabled: true
35
+ * # Antora resource ID or filename of the shared definitions partial.
36
+ * terminology_file: 'ROOT:partial$terminology-table.adoc'
37
+ * # Filename of a component's local override partial.
38
+ * local_file: 'terminology-local.adoc'
39
+ * # Filenames of the generated partials.
40
+ * terminology_partial: 'generated-terminology.adoc'
41
+ * index_partial: 'generated-index.adoc'
42
+ * # AsciiDoc cols attribute for each generated table.
43
+ * terminology_cols: '15,85'
44
+ * index_cols: '30,70'
45
+ * # 'combined' welds each letter into its group's first row (default);
46
+ * # 'separate' emits the letter as its own row (may orphan at a page
47
+ * # bottom in the PDF).
48
+ * letter_style: 'combined'
49
+ * # Attribution line rendered above the Terminology content outside
50
+ * # the PDF build. AsciiDoc inline markup allowed; empty disables.
51
+ * attribution: 'Generated by https://gitlab.com/baiyibai-antora/baiyibai-extensions[autoterm].'
52
+ *
53
+ * The including page overrides presentation per component through header
54
+ * attributes: :autoterm-terminology-cols:, :autoterm-index-cols:,
55
+ * :autoterm-letter-style:.
56
+ *
57
+ * The generated partials live in the content catalog and regenerate on every
58
+ * build. Setting write_to_disk: true additionally writes them into the
59
+ * component's local worktree; components loaded from a remote source skip
60
+ * the disk write, mirroring trademark-it.
61
+ *
62
+ * Per-component configuration in a component's antora.yml under
63
+ * ext.autoterm overrides local_file, terminology_cols, index_cols,
64
+ * letter_style, write_to_disk, and enabled for that component-version.
65
+ * Unlike trademark-it, the block is optional: participation comes from the
66
+ * include, not from the block.
67
+ */
68
+ interface AutotermConfig {
69
+ enabled: boolean;
70
+ quiet: boolean;
71
+ terminology_file: string;
72
+ local_file: string;
73
+ terminology_partial: string;
74
+ index_partial: string;
75
+ terminology_cols: string;
76
+ index_cols: string;
77
+ letter_style: 'combined' | 'separate';
78
+ attribution: string;
79
+ write_to_disk: boolean;
80
+ suppress_events: boolean;
81
+ }
82
+ export interface TermDefinition {
83
+ fullTerm: string;
84
+ abbreviation: string;
85
+ definition: string;
86
+ }
87
+ export interface IndexTerm {
88
+ /** Full term without the abbreviation parenthetical, trimmed. */
89
+ full: string;
90
+ /** Abbreviation from the trailing parenthetical, or null. */
91
+ abbr: string | null;
92
+ }
93
+ interface AntoraLogger {
94
+ debug?: (msg: string) => void;
95
+ info?: (msg: string) => void;
96
+ warn?: (msg: string) => void;
97
+ error?: (msg: string) => void;
98
+ }
99
+ interface ExtensionEntry {
100
+ require?: string;
101
+ autoterm?: Partial<AutotermConfig>;
102
+ autoTerm?: Partial<AutotermConfig>;
103
+ }
104
+ interface Playbook {
105
+ dir: string;
106
+ antora?: {
107
+ extensions?: ExtensionEntry[];
108
+ };
109
+ }
110
+ interface VirtualFileOrigin {
111
+ worktree?: string;
112
+ startPath?: string;
113
+ type?: string;
114
+ }
115
+ interface VirtualFileSrc {
116
+ path?: string;
117
+ family?: string;
118
+ component?: string;
119
+ version?: string;
120
+ module?: string;
121
+ relative?: string;
122
+ basename?: string;
123
+ stem?: string;
124
+ extname?: string;
125
+ origin?: VirtualFileOrigin;
126
+ mediaType?: string;
127
+ }
128
+ interface VirtualFile {
129
+ src: VirtualFileSrc;
130
+ contents: Buffer | Uint8Array;
131
+ }
132
+ interface ContentCatalog {
133
+ getFiles: () => VirtualFile[];
134
+ addFile: (file: {
135
+ contents: Buffer;
136
+ src: VirtualFileSrc;
137
+ }) => void;
138
+ }
139
+ interface ContentAggregateItem {
140
+ name: string;
141
+ version: string;
142
+ ext?: Record<string, Record<string, unknown>>;
143
+ }
144
+ interface Registry {
145
+ getLogger?: (name: string) => AntoraLogger;
146
+ once(event: 'contentAggregated', callback: (context: {
147
+ contentAggregate: ContentAggregateItem[];
148
+ }) => void): void;
149
+ once(event: 'playbookBuilt', callback: (context: {
150
+ playbook: Playbook;
151
+ }) => Promise<void>): void;
152
+ once(event: 'contentClassified', callback: (context: {
153
+ playbook: Playbook;
154
+ contentCatalog?: ContentCatalog;
155
+ }) => Promise<void>): void;
156
+ once(event: string, callback: (context: unknown) => void): void;
157
+ }
158
+ export declare function parseTerminologyTable(asciidocText: string): Map<string, TermDefinition>;
159
+ /**
160
+ * Merge a component-local definitions map over the shared map. A local entry
161
+ * replaces the shared entry whose full term matches exactly, mirroring the
162
+ * exact-key lookup the definitions serve; remaining local entries are added.
163
+ */
164
+ export declare function mergeTerminology(shared: Map<string, TermDefinition>, local: Map<string, TermDefinition>): {
165
+ merged: Map<string, TermDefinition>;
166
+ overridden: string[];
167
+ };
168
+ /**
169
+ * Blank the content of listing and literal blocks (---- and .... fences).
170
+ * Asciidoctor does not process index terms in verbatim context, so the
171
+ * scanner must not either; documentation showing ((...)) syntax inside a
172
+ * listing stays inert. Line count is preserved.
173
+ */
174
+ export declare function stripVerbatimBlocks(text: string): string;
175
+ export declare function scanIndexterms(sourceText: string, ignoreConditionals?: string[]): IndexTerm[];
176
+ interface TerminologyEntry {
177
+ label: string;
178
+ body: string;
179
+ sortKey: string;
180
+ letter: string;
181
+ }
182
+ /**
183
+ * Build the terminology entries from the scanned terms and the merged
184
+ * definitions, applying the ledger rules: a term with an abbreviation always
185
+ * appears; a term without one appears only when it has a definition; the
186
+ * entry label is the abbreviation or the full term; the body is
187
+ * "Full Term – definition" for abbreviated terms, the definition alone
188
+ * otherwise; duplicate full terms keep the last-scanned occurrence.
189
+ */
190
+ export declare function buildTerminologyEntries(terms: IndexTerm[], definitions: Map<string, TermDefinition>): TerminologyEntry[];
191
+ export declare function generateTerminologyPartial(entries: TerminologyEntry[], cols?: string, letterStyle?: 'combined' | 'separate', attribution?: string): string;
192
+ export interface IndexOccurrence {
193
+ display: string;
194
+ sortKey: string;
195
+ letter: string;
196
+ /** xref targets: module, relative, page title */
197
+ pages: Array<{
198
+ module: string;
199
+ relative: string;
200
+ title: string;
201
+ }>;
202
+ }
203
+ export declare function generateIndexPartial(occurrences: IndexOccurrence[], cols?: string): string;
204
+ /** Extract the page title from raw AsciiDoc source. */
205
+ export declare function pageTitle(sourceText: string): string;
206
+ /** Read a :name: value from a raw page header, or null. */
207
+ export declare function pageAttribute(sourceText: string, name: string): string | null;
208
+ export declare function register(this: Registry, context?: Registry): void;
209
+ export {};
210
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/extensions/autoterm/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AAWH,UAAU,cAAc;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;IACf,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,UAAU,GAAG,UAAU,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,SAAS;IACxB,iEAAiE;IACjE,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB;AAED,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9B,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,IAAI,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,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