asciidoctor-rhrev 1.0.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.
data/USAGE.adoc ADDED
@@ -0,0 +1,653 @@
1
+ = rhrev Asciidoctor Revision History Extension
2
+ :toc: macro
3
+
4
+ A comprehensive revision history tracking system for AsciiDoctor and Antora that automatically creates a grouped, formatted table of document changes with clickable page numbers.
5
+
6
+ toc::[]
7
+
8
+ == Key Features
9
+
10
+
11
+ * [x] *Revision Grouping* +
12
+ Organize changes by revision number (1-1, 1-2, 2-1, etc.)
13
+ * [x] *AST Pre-scanning* +
14
+ Collects entries before rendering (like ToC) for accurate page allocation
15
+ * [x] *Automatic Page Allocation* +
16
+ Properly allocates multi-page tables without overprinting
17
+ * [x] *Clickable Page Numbers* +
18
+ Page numbers link directly to changed content
19
+ * [x] *Bullet Point Lists* +
20
+ Changes formatted as proper bullet lists with nesting
21
+ * [x] *Bold Headers* +
22
+ "Major changes since..." headers are bold and clear
23
+ * [x] *Document-Level Entries* +
24
+ Special "all" and "cover" page entries
25
+ * [x] *Block-Level Tracking* +
26
+ Sections, examples, listings, tables, and figures
27
+ * [x] *Multiple Placement Options* +
28
+ Auto placement or manual with `rhrev::[]` macro
29
+ * [x] *Flexible Display* +
30
+ Render as section or standalone table
31
+ * [x] *Table Styling* +
32
+ Control frame, grid, stripes, alignment, and caption
33
+ * [x] *Localization* +
34
+ Customize all labels and text
35
+ * [x] *Export to .adoc* +
36
+ Export revision history to separate file
37
+ * [x] *Pre/Post Content* +
38
+ Add custom content before/after the table
39
+ * [x] *TOC-like Syntax* +
40
+ Use `:rhrev: macro` just like `:toc: macro`
41
+
42
+ == Basic Usage
43
+
44
+ [source,asciidoc]
45
+ ----
46
+ = My Document
47
+ :doctype: book
48
+ :rhrev:
49
+ ----
50
+
51
+ === Define Revision Metadata
52
+
53
+ [source,asciidoc]
54
+ ----
55
+ // Revision 1.1 metadata
56
+ :1-1-prevrev: 1.0
57
+ :1-1-prevrevdate: 2024-01-01
58
+ :rhrev1-1-all: * Initial document structure * Added core sections * Setup formatting
59
+ :rhrev1-1-cover: * Updated cover design * New logo
60
+ ----
61
+
62
+ [IMPORTANT]
63
+ *All revision attributes must be defined in the document header* - before the first blank line after the document title.
64
+ Asciidoctor only loads attributes from the header section.
65
+ Attributes that are placed after a blank line do not appear in the revision history.
66
+
67
+ .Correct ✅
68
+ [source,asciidoc]
69
+ ----
70
+ = My Document
71
+ :doctype: book
72
+ :rhrev:
73
+ :version-label: Version
74
+ // Revision 1.0 metadata
75
+ :1-1-prevrev: 1.0
76
+ :1-1-prevrevdate: 2024-01-01
77
+ :rhrev1-1-all: Initial release
78
+
79
+ == Chapter One
80
+ ----
81
+
82
+ .Incorrect ❌
83
+ [source,asciidoc]
84
+ ----
85
+ = My Document
86
+ :doctype: book
87
+ :rhrev:
88
+ :version-label: Version
89
+
90
+ // ❌ This blank line ends the header!
91
+ :1-1-prevrev: 1.0 // ❌ These attributes will be IGNORED
92
+ :rhrev1-1-all: Initial release // ❌ They won't appear in output
93
+
94
+ == Chapter One
95
+ ----
96
+
97
+ Pro Tip:: Use comments like `// Revision 1.0 metadata` between revision groups instead of blank lines to keep everything in the header while maintaining readability.
98
+
99
+ === Mark Content Blocks
100
+
101
+ [source,asciidoc]
102
+ ----
103
+ [rhrev1-1="Created introduction section * Added
104
+ overview"]
105
+ == Introduction
106
+
107
+ Content here...
108
+
109
+
110
+ [rhrev1-1="Added installation guide * Included prerequisites"]
111
+ [rhrev1-2="Re-ordered the installation steps * Added overview"]
112
+ == Getting Started
113
+
114
+ More content...
115
+ ----
116
+
117
+ That's it! The extension performs several actions:
118
+
119
+ . Pre-scans the document AST to collect all revision entries
120
+ . Allocates proper space for the revision history table
121
+ . Renders content normally and capture page numbers
122
+ . Fills in the revision history table with actual data and clickable links
123
+
124
+ == Understanding Revisions
125
+
126
+ Revisions use a hierarchical numbering system: `major-minor` (e.g., 1-1, 1-2, 2-1).
127
+
128
+ Each revision groups changes into:
129
+
130
+ Document-level "all" entry:: Overall changes for the entire document
131
+ Document-level "cover" entry:: Cover page changes (PDF only, not in HTML)
132
+ Block-level entries:: Specific changes to sections, examples, etc.
133
+
134
+ == Configuration Attributes
135
+
136
+ The extension is highly-configurable.
137
+
138
+ .Core Settings
139
+ [%header,cols="25,75"]
140
+ |===
141
+ |Attribute
142
+ |Description
143
+
144
+ |`:rhrev:`
145
+ |Enable the feature
146
+
147
+ |`:rhrev: macro`
148
+ |Enable with macro placement, +
149
+ similar to the +
150
+ `:toc: macro` +
151
+ `toc::[]`
152
+
153
+ |`:rhrev-block-type:`
154
+ a|
155
+ * `section` (default)
156
+ * `table`
157
+
158
+ |`:rhrev-discrete:`
159
+ |Exclude from the Table of Contents +
160
+ (`:rhrev-block-type: section` only)
161
+
162
+ |`:rhrev-suppress-new-page-after:`
163
+ a|Suppress automatic new page after revision history table +
164
+
165
+ * Allows content to continue on the same page.
166
+
167
+ |`:rhrev-disable-caption:`
168
+ a|
169
+ * Disable "Table N." caption prefix
170
+
171
+ |`:rhrev-table-caption: <Custom Caption>`
172
+ |Custom table caption text
173
+
174
+ |`:rhrev-description-xrefstyle: basic`
175
+ a|Sets the `xrefstyle` inside the description column.
176
+
177
+ * `full`
178
+ * `short`
179
+ * `basic`
180
+ * `short basic` +
181
+ Like `full`, but without comma, italics, or bold styling.
182
+
183
+ |`:rhrev-customization-xrefstyleshort-remove-trailling-period:`
184
+ |Removes the trailing period from xrefstyleshort.
185
+
186
+ |`:rhrev-initial-handling:`
187
+ a|Controls behavior when revnumber is 1.0 or 1
188
+
189
+ * `initial-release` (default) - Renders simplified table with "Initial release" text
190
+ * `skip` - Completely skip revision history rendering
191
+ * `normal` - Render normally even for version 1.0
192
+
193
+ |`:rhrev-customization-title:`
194
+ a|Custom title for revision history section +
195
+ Default: "{version-label} History" +
196
+ Set to empty string to suppress title
197
+
198
+ |===
199
+
200
+ .Localization and Customization
201
+ [%header,cols="25,75"]
202
+ |===
203
+ |Attribute
204
+ |Default
205
+
206
+ |`:rhrev-table-caption:`
207
+ |Custom Caption
208
+
209
+ |`:rhrev-localization-page:`
210
+ |Page
211
+
212
+ |`:rhrev-localization-major-changes:`
213
+ |Major changes since
214
+
215
+ |`:rhrev-localization-all:`
216
+ |All
217
+
218
+ |`:rhrev-localization-cover:`
219
+ |Cover
220
+
221
+ |`:rhrev-localization-initial-release:`
222
+ |Initial release
223
+
224
+ |`:rhrev-customization-prevrev-include-date:`
225
+ a|Include date in revision headers +
226
+ When set, date appears after revision: "Version 1.0 2024-01-15" +
227
+ When unset, only version: "Version 1.0" (default)
228
+
229
+ |`:rhrev-customization-date-format:`
230
+ |Date format string for prevrev dates +
231
+ Default: %Y-%m-%d +
232
+ Example: %B %d, %Y → January 15, 2025
233
+
234
+ |`:rhrev-customization-initial-release-text:`
235
+ |Text to display for initial release (v1.0) +
236
+ Default: Initial Release
237
+
238
+ |===
239
+
240
+ .Advanced Options
241
+ [%header,cols="25,75"]
242
+ |===
243
+ |Attribute
244
+ |Description
245
+
246
+ |`:revhistoryprefix:`
247
+ a|Override the default attribute prefix +
248
+ Default: rhrev +
249
+ Example: `:revhistoryprefix: rev` changes `rhrev1-1` to `rev1-1`
250
+
251
+ [WARNING]
252
+ Changing this value may have adverse effects.
253
+
254
+ |`:rhrev-customization-description-format:`
255
+ a|Control what appears in description column +
256
+ Options:
257
+
258
+ * `xref,desc` (default) - Show xref and description
259
+ * `xref` - Show only xref
260
+ * `desc` - Show only description
261
+
262
+ |`:rhrev-debug:`
263
+ |Enable debug logging for troubleshooting +
264
+ Outputs to stderr or logger
265
+
266
+ |===
267
+
268
+ .Table Styling
269
+ [%header,cols="25,75"]
270
+ |===
271
+ |Attribute
272
+ |Default
273
+
274
+ |`:rhrev-table-column-width:`
275
+ |30,70
276
+
277
+ |`:rhrev-table-frame:`
278
+ a|Table frame styling
279
+
280
+ * all
281
+ * sides
282
+ * ends
283
+ * none
284
+
285
+ |`:rhrev-table-grid:`
286
+ a|Table grid styling
287
+
288
+ * all
289
+ * rows
290
+ * cols
291
+ * none
292
+
293
+ |`:rhrev-table-stripes:`
294
+ a|Table stripe styling
295
+
296
+ * even
297
+ * odd
298
+ * none
299
+
300
+ |`:rhrev-table-stripes-color:`
301
+ a|Table stripe color
302
+
303
+ * Hex color for stripes (default: 'EEEEEE')
304
+
305
+ |`:rhrev-table-extra-blank-row:`
306
+ a|Add blank row at end of table +
307
+ (Uses non-breaking spaces for proper height)
308
+
309
+ |===
310
+
311
+
312
+ The <<table-inserted-row>> attributes allow the author to insert a custom row into the table.
313
+ All support full AsciiDoc markup (bold, italic, admonitions, lists, etc.)
314
+
315
+ NOTE: Custom first row is supported in both embedded output and exported .adoc files.
316
+
317
+ [#table-inserted-row]
318
+ .Inserted Row
319
+ [%header,cols="25,75"]
320
+ |===
321
+ |Attribute
322
+ |Default
323
+
324
+ |`:rhrev-customization-first-row:`
325
+ |Content to add to the first row which spans both columns
326
+
327
+ |`:rhrev-customization-first-row-left:`
328
+ |Content for left cell of first row
329
+
330
+ |`:rhrev-customization-first-row-right:`
331
+ |Content for right cell of first row
332
+
333
+
334
+ |`:rhrev-export-to-file:`
335
+ |Enable export to .adoc file
336
+
337
+ |`:rhrev-adoc-output:`
338
+ |Output filename +
339
+ default: revhistory.adoc
340
+
341
+ |`:rhrev-export-format:`
342
+ a|Export format:
343
+
344
+ * 'xref' (default) - exports with the `xref:anchor[page]` macro in the left column
345
+ * 'pagerhref' - exports with the `pagerhref:anchor[]` macro in the left column
346
+
347
+ NOTE: Antora Assembler beta.15 xref format (`xref:file/path:::anchor[]`) xrefs are automatically converted to standard format (`xref:filename.adoc#anchor[]`) during export
348
+
349
+ |===
350
+
351
+ === Theme Support
352
+
353
+ rhrev supports three asciidoctor theme keys for styling output:
354
+
355
+ * `rhrevpage`
356
+ * `rhrevdescription`
357
+ * `pagerhref`
358
+
359
+ == Initial Release Handling
360
+
361
+ When `:revnumber:` is set to `1.0` or `1`, the extension provides special handling:
362
+
363
+ .Default Behavior (`:rhrev-initial-handling: initial-release`)
364
+ Renders a simplified table with "Initial release" text instead of showing empty revision history.
365
+
366
+ [source,asciidoc]
367
+ ----
368
+ = My Document
369
+ :revnumber: 1.0
370
+ :rhrev:
371
+ :rhrev-initial-handling: initial-release
372
+ ----
373
+
374
+ This produces a clean table showing:
375
+
376
+ [cols="30,70"]
377
+ |===
378
+ a|*Page* | a|*Initial release*
379
+ | {nbsp} | {nbsp}
380
+ |===
381
+
382
+ .Skip Rendering (`:rhrev-initial-handling: skip`)
383
+ Completely skip revision history rendering for initial release.
384
+
385
+ Use `:rhrev: macro` to avoid a blank page being inserted at the beginning of the document.
386
+
387
+ [source,asciidoc]
388
+ ----
389
+ :revnumber: 1.0
390
+ :rhrev: macro
391
+ :rhrev-initial-handling: skip
392
+ ----
393
+
394
+ .Normal Rendering (`:rhrev-initial-handling: normal`)
395
+ Render revision history normally even for version 1.0:
396
+
397
+ [source,asciidoc]
398
+ ----
399
+ :revnumber: 1.0
400
+ :rhrev:
401
+ :rhrev-initial-handling: normal
402
+ :1-0-prevrev: 0.9
403
+ :rhrev1-0-all: First stable release
404
+ ----
405
+
406
+ == Manual Mode (`:rhrev: manual`)
407
+
408
+ Manual mode allows authors to hand-craft revision history tables, while still leveraging the rhrev extension's anchor cataloging functionality.
409
+ This allows authors to use the `pagerhref` macro to resolve page numbers, which eliminates the need to manually track page numbers.
410
+
411
+ Use manual mode when these requirements are needed:
412
+
413
+ * *Full control* over table structure and formatting
414
+ * *Custom grouping* of changes by version/date
415
+ * *Flexible layout* not constrained by auto-generation
416
+ * *Clickable page number links* via `pagerhref` macro
417
+
418
+ What it does not do:
419
+
420
+ * Does *NOT* build a revision history table
421
+ * Does *NOT* collect or process revision attributes
422
+ * Does *NOT* create automatic revision entries
423
+
424
+
425
+ === Usage Example
426
+
427
+ [source,asciidoc]
428
+ ----
429
+ = My Document
430
+ :doctype: book
431
+ :rhrev: manual
432
+
433
+ == Revision History
434
+
435
+ .Version History
436
+ [cols="1,3"]
437
+ |===
438
+ |Page
439
+ |Changes
440
+
441
+ a|pagerhref:_introduction[]
442
+ a| xref:_introduction[Introduction]
443
+
444
+ * Created new section
445
+
446
+ a|pagerhref:_features[]
447
+ a|xref:_features[Features]
448
+
449
+ * Added advanced features
450
+
451
+ |===
452
+
453
+ == Introduction
454
+
455
+ Content here...
456
+
457
+ == Features
458
+
459
+ More content...
460
+ ----
461
+
462
+ === How pagerhref Works
463
+
464
+ The `pagerhref:anchor[]` macro uses *deferred rendering* to resolve both forward and backward references:
465
+
466
+ 1. *First Pass*: Tables with `pagerhref` macros are measured and space is allocated
467
+ 2. *Cataloging*: All sections/blocks with anchors are cataloged with their page numbers during rendering
468
+ 3. *Re-rendering*: After document rendering completes, tables are re-rendered with actual page numbers
469
+ 4. *Result*: Clickable page number links that work for all references
470
+
471
+ === Benefits vs. Auto Mode
472
+
473
+ [cols="1,2,2"]
474
+ |===
475
+ | Aspect | Auto Mode | Manual Mode
476
+
477
+ | Table Generation
478
+ | Automatic
479
+ | Hand-crafted
480
+
481
+ | Flexibility
482
+ | Structured format
483
+ | Complete control
484
+
485
+ | Page Links
486
+ | Automatic
487
+ | Via `pagerhref` macro
488
+
489
+ | Best For
490
+ | Standard revision tracking
491
+ | Custom layouts, specific requirements
492
+ |===
493
+
494
+ == Usage Examples
495
+
496
+ Refer to the /tests folder to see real examples.
497
+
498
+ == Troubleshooting
499
+
500
+ * Page numbers show as "???"
501
+ ** Ensure images resolve
502
+
503
+ * Bullets render as asterisks
504
+ ** Check for syntax errors in bullet formatting
505
+ ** Ensure asterisks have spaces: `* item` not `*item`
506
+ ** Nested bullets need multiple asterisks: `** nested`
507
+
508
+ == Antora Assembler (PDF Extension) Compatibility and Configuration
509
+
510
+ Using the rhrev extension with either the default embedded, `rhrev: ''` or `macro` mode requires no additional configuration.
511
+
512
+ Using `rhrev: manual` mode with content which contains the `rhrev-export-format: pagerhref` requires additional steps:
513
+
514
+ . [`antora-assembler.yml`] Add the rhrev extension as the last item (`-r `) in the `build/command`. +
515
+ This is required to ensure the extension overrides the table rendering so that it can provide page numbers to the catalog.
516
+ . [`antora-playbook.yml`] Add the Antora-Assembler `antora-rhrev-assembler-pagerhref.js` script to the `antora/extensions` section. +
517
+ This extension overwrites the pagerhref macros in exported in the assembly file to allow page lookup in the catalog.
518
+
519
+ The recommended approach is to add some rhrev entires in the document, export the revision history to an .adoc file, and then examine it to see how to copy and re-import the content.
520
+
521
+ == Antora Usage
522
+
523
+ Until the extension is available on npm or yarn, the extensions must be manually configured in the `antora-playbook.yml` file.
524
+
525
+ . Add these lines to the `antora-playbook.yml`:
526
+ +
527
+ [source,yaml]
528
+ ----
529
+ asciidoc:
530
+ extensions:
531
+ - ./antora-extension/antora-rhrev-asciidoc.js
532
+ antora:
533
+ extensions:
534
+ - '@antora/pdf-extension'
535
+ # Select only one
536
+ - require: ./antora-extension/antora-rhrev-html.js
537
+ - require: ./antora-extension/antora-rhrev-placeholder.js
538
+ # Required if using rhrev: manual w/pagerhref macros:
539
+ - require: ./antora-extension/antora-rhrev-assembler-pagerhref.js
540
+ ----
541
+ +
542
+ . Add the desired configuration settings into the appropriate .yml file; antora-assembler.yml for PDF and antora-playbook.yml for HTML.
543
+ . For best results, use the `rhrev: macro` attribute in the document.
544
+
545
+ == The Tao of Revision History
546
+
547
+ === Writing Good Revision Descriptions
548
+
549
+ A good revision history is not a list of "updated" and "fixed bugs."
550
+ It's a narrative that respects the reader's time and helps them understand what changed without comparing two versions.
551
+
552
+ . Use simple past tense verbs with specificity
553
+ ** [x] "Added OAuth 2.0 authentication"
554
+ ** [x] "Changed timeout from 30s to 60s"
555
+ ** [x] "Removed deprecated API endpoints"
556
+ ** ❌ "Updated authentication"
557
+ ** ❌ "Fixed issues"
558
+ ** ❌ "Improvements made"
559
+ . Describe the transition (from → to):
560
+ ** [x] "Changed default port from 8080 to 3000"
561
+ ** [x] "Renamed 'config.yaml' to 'settings.yaml'
562
+ ** ❌ "Port updated"
563
+ ** ❌ "Config file changed"
564
+ . Keep simple styling and avoid too many hyperlinks.
565
+ . Keep changes next to the context.
566
+
567
+ === Why Use Block Attributes?
568
+
569
+ When placed `[rhrev1-2="Added validation"]` directly on a section about user input, the editor immediately knows WHAT was validated and WHERE. This is better than a separate changelog that says "Added validation" with no context.
570
+
571
+ The problem with separate changelogs::
572
+
573
+ * The author must remember what changed
574
+ * The reader must hunt through document to find the change
575
+ * Vague entries like "updated section 3.2" are useless
576
+ * Maintaining two files is error-prone
577
+
578
+ The solution with inline attributes::
579
+
580
+ * The change description is right at the change location
581
+ * This forces author to think about the change while making it
582
+ * The reader gets a descriptive preview of the change in advance
583
+ * There is a single source of truth
584
+
585
+ == The Frustration This Avoids
586
+
587
+ When maintaining a 200-page technical manual, tracking changes in a separate file becomes a nightmare:
588
+
589
+ * "Which section did I update?"
590
+ * "Was it the API reference or the examples?"
591
+ * "What exactly changed in chapter 5?"
592
+
593
+ With inline `[rhrev]` attributes, the change description lives with the change.
594
+
595
+
596
+ === Document-Level vs Block-Level Entries
597
+
598
+ Document-level "all" Entries::
599
+
600
+ * Structural changes (added new chapter, reorganized sections)
601
+ * Format updates (changed heading styles, updated templates)
602
+ * Global find-replace operations
603
+ * Overall improvements that touch many places
604
+
605
+ Block-level Entries:::
606
+
607
+ * Specific content changes (added example, updated diagram)
608
+ * Localized fixes (corrected formula, fixed typo)
609
+ * New content (added section on X)
610
+ * Targeted updates (revised explanation of Y)
611
+
612
+ === The Asterisk System
613
+
614
+ Asterisks create hierarchy in the changes:
615
+
616
+ [source,asciidoc]
617
+ ----
618
+ :rhrev1-2-all: Added security chapter * Authentication ** OAuth 2.0 ** API keys * Authorization ** Role-based access ** Permissions
619
+ ----
620
+
621
+ This renders as:
622
+
623
+ * Added security chapter
624
+ * Authentication
625
+ ** OAuth 2.0
626
+ ** API keys
627
+ * Authorization
628
+ ** Role-based access
629
+ ** Permissions
630
+
631
+ One bullet per change, subbullets for more detail
632
+
633
+ === Minimal Styling is Better
634
+
635
+ Revision histories should be scannable, not distracting:
636
+
637
+ * Plain text is best for change descriptions
638
+ * Bold headers (automatic) help separate revisions
639
+ * Bullet points (automatic) organize changes
640
+ * Clickable page numbers (automatic) for navigation
641
+ * That's it. No colors, no icons, no fancy formatting.
642
+
643
+ The goal is clarity, not decoration. Your readers are looking for information, not entertainment.
644
+
645
+ === Teaching Better Documentation
646
+
647
+ This extension teaches authors to think more deeply about their changes:
648
+
649
+ * What exactly changed?
650
+ * Why did it change?
651
+ * How would I explain this to someone who doesn't have the previous version?
652
+
653
+ This discipline improves documentation quality overall.