sphinx-last-updated-by-git¶
Project Homepage¶
https://pypi.org/project/sphinx-last-updated-by-git/
Project links
Homepage
Statistics
GitHub statistics:
Stars: 12
Forks: 2
Open issues/PRs: 2
Meta License: BSD License (BSD-2-Clause)
Author: Matthias Geier
Tags Sphinx, Git
Requires: Python >=3.6
Maintainers Avatar for Matthias.Geier from gravatar.com Matthias.Geier
Get the “last updated” time for each Sphinx page from Git¶
This is a little Sphinx extension that does exactly that. It also checks for included files and other dependencies and uses their “last updated” time if it’s more recent.
If a page doesn’t have a source file, its last_updated time is set to None.
The default value for html_last_updated_fmt is changed
from None to the empty string.
- Usage
Install the Python package
sphinx-last-updated-by-gitAdd
'sphinx_last_updated_by_git'toextensionsin yourconf.pyRun Sphinx!
- Options
If a source file is not tracked by Git (e.g. because it has been auto-generated on demand by autosummary_generate) but its dependencies are, the last_updated time is taken from them. If you don’t want this to happen, use
git_untracked_check_dependencies = False.If a source file is not tracked by Git, its HTML page doesn’t get a source link. If you do want those pages to have a sourcelink, set
git_untracked_show_sourcelink = True. Of course, in this case html_copy_source and html_show_sourcelink must also beTrue, and the theme you are using must support source links in the first place.By default, timestamps are displayed using the local time zone. You can specify a datetime.timezone object (or any
tzinfosubclass instance) with the configuration optiongit_last_updated_timezone. You can also use any string recognized by babel, e.g.git_last_updated_timezone = 'NZ'.By default, the “last updated” timestamp is added as an HTML
<meta>tag. This can be disabled by setting the configuration optiongit_last_updated_metatagstoFalse.
- Caveats
When using a “Git shallow clone” (with the
--depthoption), the “last updated” commit for a long-unchanged file might not have been checked out. In this case, the last_updated time is set toNone(and a warning is shown during the build).This might happen on https://readthedocs.org/ because they use shallow clones by default. The
DONT_SHALLOW_CLONEfeature flag should fix this.If you want to get rid of the warning, use this in your
conf.py:suppress_warnings = ['git.too_shallow']
When a project on https://readthedocs.org/ using their default theme
sphinx_rtd_themewas created before October 20th 2020, the date will not be displayed in the footer.One work-around is to enable the (undocumented) feature flag
USE_SPHINX_LATEST.Another work-around is to override the defaults by means of a
requirements.txtfile containing something like this:sphinx>=2 sphinx_rtd_theme>=0.5
See also issue #1.
- License
BSD-2-Clause (same as Sphinx itself), for more information take a look at the
LICENSEfile.- Similar stuff
Last change: Tue, 03 Aug 2021 10:25 PM UTC