Clarify which version of source code was used to generate docs
Currently when yard generates docs it attaches the following footer:
Generated on Tue Nov 19 15:01:10 2024 by [yard](http://yardoc.org/) 0.9.36 (ruby-3.3.5).
Which is not enough to understand which version of the source code was used:
- No time zone information on timestamp
- No git commit hash
- No library version.
Ideally all of that need to be present to understand if the doc is up to date or not. Please add this information to footer.
Adding a timezone to the timestamp seems reasonable. Would accept a PR to fix this.
As far as git commit hash and library version, these aren't something that YARD necessarily knows about. Git commit would require integrating with the system VCS which has a lot of sharp edges (git isn't in the PATH, contents generated against dirty checkout so SHA isn't valid, VCS might not be git, YARD opens itself up to fielding feature requests for <insert VCS tool here>). Getting the library version is even harder as there is no static way to get this information without evaluating code.
The good news is you can build a custom template footer pretty easily with all the information you want by throwing a file into <path/to>/default/layout/html/footer.erb with any contents (you can grab initial contents from YARD's footer.erb) and then running yard with yard doc -p path/to (path/to was the prefix you used above for the file location).
<!-- templates/default/layout/html/footer.erb -->
<div id="footer">
Generated <code>MY_LIBRARY</code> <%= YARD::VERSION %> <!-- insert your library's VERSION const here -->
(<%= `git rev-parse HEAD`.strip[0,6] %>) at <%= Time.now %>.
</div>
Getting the library version is even harder as there is no static way to get this information without evaluating code.
I saw this fragment here and thought it is possible:
<script>
window.yard_library_name = '<%= @library.name %>';
window.yard_library_version = '<%= @library.version %>';
</script>
https://github.com/docmeta/rubydoc.info/blob/main/templates/default/layout/html/footer.erb#L8
Rubydoc intentionally pulls information that yard alone does not have-- specifically the rubygems package release list or git repos. That's because rubydoc explicitly pulls from these sources. YARD only uses disk.