Get the "last updated" time for each Sphinx page from Git
Project description
This is a little Sphinx extension that does exactly that.
It also checks for included files and other dependencies.
If a page doesn’t have a source file, its last_updated time is set to None.
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 be True, and the theme you are using must support source links in the first place.
The default value for html_last_updated_fmt is changed from None to the empty string.
By default, timestamps are displayed using the local time zone. You can specify a datetime.timezone object (or any tzinfo subclass instance) with the configuration option git_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 option git_last_updated_metatags to False.
- Usage
Install the Python package sphinx-last-updated-by-git
Add 'sphinx_last_updated_by_git' to extensions in your conf.py
Run Sphinx!
- Caveats
When using a “Git shallow clone” (with the --depth option), the “last updated” commit for a long-unchanged file might not have been checked out. In this case, the last_updated time is set to None (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_CLONE feature should fix this.
If you want to get rid of the warning, use this in your conf.py:
suppress_warnings = ['git.too_shallow']
The date might not be displayed on https://readthedocs.org/ when using the sphinx_rtd_theme (which is their default). See issue #1.
- License
BSD-2-Clause (same as Sphinx itself), for more information take a look at the LICENSE file.
- Similar stuff
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for sphinx-last-updated-by-git-0.2.4.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d05b0eb7e76bdba2a4a6da0716294db6004d0c74625e6464575ad927049b90b5 |
|
MD5 | 745e7cdf56972cd6d4609c46a7541625 |
|
BLAKE2b-256 | 65e305bcb96f3eec5876dd0c5e8addbc93603ed1bafae98812ca8efa595abfc9 |
Hashes for sphinx_last_updated_by_git-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1c3cd57158adbce89f44667840c85d523a040f5c5ad3d45fe939c86a5c11023 |
|
MD5 | 3a2cc442c767b33f22950c561f5394a9 |
|
BLAKE2b-256 | e9ebd24341e2427b2cafed459cd34f9de90a7315bbadc9aa2077180f7b8ef2ac |