asciidocantora

Why do asciidoc attributes docdatetime and localdatetime always display the same value?


Make an .adoc file with this content:

Last modified: {docdatetime} +
Last converted: {localdatetime}

Both lines display the same value (time of conversion) in preview (Ctrl+K, V) and in HTML output of Antora. Closing preview and re-opening it updates both values to current time.

I'm using VSCode in Windows.
The file modification date does not change in the file explorer.

From the documentation I expect the first line to always display the datetime of last modification of the file. The second line should be displaying the datetime of the last conversion. So if I run another generation on the same unmodified file, docdatetime should stay the same, localdatetime should update.
asciidoc-attributes

Why do preview and Antora output always display the same datetime in both lines? How to display the date of last modification?


Solution

  • Yours is a two-part question:

    1. When previewing with the AsciiDoc plugin for VS Code, the source for the preview is the editor window, not the file on disk. I'm guessing the plugin fetches the last modified time from the file when opening the preview and then caches that value for subsequent preview updates.

      Think about it this way: your expectation would imply no preview updates as you type unless you save the file.

    2. For Antora, all content is gathered from Git repos. Antora does not attempt to find the last modification time because it could require scanning most/all repo history to determine that. Git isn't optimized to answer that question. You might not normally see any delay when running git log manually, but on large repos, that can take a while. Antora would potentially have to make that determination for every file, leading to very long build times.

      So, when you run Antora, those attributes are populated when transformation occurs.

      It would be possible to use a commit hook to maintain a local database of file modification times, and use an Antora extension to populate those attributes from the database.