Skip to main content

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
  1. Install the Python package sphinx-last-updated-by-git

  2. Add 'sphinx_last_updated_by_git' to extensions in your conf.py

  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sphinx-last-updated-by-git-0.2.3.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file sphinx-last-updated-by-git-0.2.3.tar.gz.

File metadata

  • Download URL: sphinx-last-updated-by-git-0.2.3.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for sphinx-last-updated-by-git-0.2.3.tar.gz
Algorithm Hash digest
SHA256 eeb352936e00938169d05884c9872de4b34c40b8d57b61a50d7ddf92891e072f
MD5 9baca5e0c20c0e38f96b1b00e3bb972b
BLAKE2b-256 b785928108ebb043d768c931722fae8a5be8afec13904487b865007b10788baa

See more details on using hashes here.

File details

Details for the file sphinx_last_updated_by_git-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: sphinx_last_updated_by_git-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for sphinx_last_updated_by_git-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7dd937badf324e3f6dc43a866d9753531d68e0107a6593c14897a32a2cac86a7
MD5 04c1f9e3bddfe6b46e4014a578dc303a
BLAKE2b-256 a91beb33b92f2acfa65414d6ee07684182ea94310c9f9f6c4e084e0eabcf4c68

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page