sphinx-last-updated-by-git


Namesphinx-last-updated-by-git JSON
Version 0.3.7 PyPI version JSON
download
home_pagehttps://github.com/mgeier/sphinx-last-updated-by-git/
SummaryGet the "last updated" time for each Sphinx page from Git
upload_time2024-05-04 15:52:54
maintainerNone
docs_urlNone
authorMatthias Geier
requires_python>=3.7
licenseBSD-2-Clause
keywords sphinx git
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            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.
For each file, the "author date" of the Git commit where it was last changed
is taken to be its "last updated" time.  Uncommitted changes are ignored.

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-git``
    #. Add ``'sphinx_last_updated_by_git'`` to ``extensions`` in your ``conf.py``
    #. Run 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 be ``True``, 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 ``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 = 'Pacific/Auckland'``.

    * 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``.

    * Files can be excluded from the last updated date calculation by passing
      a list of exclusion patterns to the configuration option
      ``git_exclude_patterns``.
      These patterns are checked on both source files and dependencies
      and are treated the same way as Sphinx's exclude_patterns_.

    * Individual commits can be excluded from the last updated date
      calculation by passing a list of commit hashes to the configuration
      option ``git_exclude_commits``.

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.
      To avoid this problem, you can edit your config file ``.readthedocs.yml``:

      .. code:: yaml

          version: 2
          build:
            os: "ubuntu-22.04"
            tools:
              python: "3"
            jobs:
              post_checkout:
                - git fetch --unshallow || true

      For more details, `read the docs`__.

      __ https://docs.readthedocs.io/en/latest/build-customization.html#unshallow-git-clone

      This might also happen when using Github Actions,
      because `actions/checkout`__ also uses shallow clones by default.
      This can be changed by using ``fetch-depth: 0``:

      .. code:: yaml

          steps:
            - uses: actions/checkout@v3
              with:
                fetch-depth: 0

      __ https://github.com/actions/checkout

      If you only want to get rid of the warning (without actually fixing the problem),
      use this in your ``conf.py``::

          suppress_warnings = ['git.too_shallow']

    * When a project on https://readthedocs.org/ using their default theme
      ``sphinx_rtd_theme`` was 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.txt`` file containing something like this::

          sphinx>=2
          sphinx_rtd_theme>=0.5

      See also `issue #1`_.

    * In Sphinx versions 5.0 and 5.1, there has been
      a regression in how dependencies are determined.
      This could lead to spurious dependencies
      which means that some "last changed" dates were wrong.
      This has been fixed in Sphinx version 5.2 and above.

      See also `issue #40`_.

License
    BSD-2-Clause (same as Sphinx itself),
    for more information take a look at the ``LICENSE`` file.

Similar stuff
    | https://github.com/jdillard/sphinx-gitstamp
    | https://github.com/OddBloke/sphinx-git
    | https://github.com/MestreLion/git-tools (``git-restore-mtime``)
    | https://github.com/TYPO3-Documentation/sphinxcontrib-gitloginfo

.. _Sphinx: https://www.sphinx-doc.org/
.. _last_updated: https://www.sphinx-doc.org/en/master/
    templating.html#last_updated
.. _exclude_patterns: https://www.sphinx-doc.org/en/master/usage/
    configuration.html#confval-exclude_patterns
.. _autosummary_generate: https://www.sphinx-doc.org/en/master/
    usage/extensions/autosummary.html#confval-autosummary_generate
.. _html_copy_source: https://www.sphinx-doc.org/en/master/
    usage/configuration.html#confval-html_copy_source
.. _html_show_sourcelink: https://www.sphinx-doc.org/en/master/
    usage/configuration.html#confval-html_show_sourcelink
.. _html_last_updated_fmt: https://www.sphinx-doc.org/en/master/
    usage/configuration.html#confval-html_last_updated_fmt
.. _datetime.timezone: https://docs.python.org/3/library/
    datetime.html#timezone-objects
.. _babel: https://babel.pocoo.org/
.. _feature flag: https://docs.readthedocs.io/en/latest/
    guides/feature-flags.html
.. _issue #1: https://github.com/mgeier/sphinx-last-updated-by-git/issues/1
.. _issue #40: https://github.com/mgeier/sphinx-last-updated-by-git/issues/40

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mgeier/sphinx-last-updated-by-git/",
    "name": "sphinx-last-updated-by-git",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "Sphinx, Git",
    "author": "Matthias Geier",
    "author_email": "Matthias.Geier@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/f0/e7/262832f58170e132f5cc546bc6fb260d7651d244e3ae4606e8aba3e109ba/sphinx_last_updated_by_git-0.3.7.tar.gz",
    "platform": "any",
    "description": "Get the \"last updated\" time for each Sphinx page from Git\n=========================================================\n\nThis is a little Sphinx_ extension that does exactly that.\nIt also checks for included files and other dependencies and\nuses their \"last updated\" time if it's more recent.\nFor each file, the \"author date\" of the Git commit where it was last changed\nis taken to be its \"last updated\" time.  Uncommitted changes are ignored.\n\nIf a page doesn't have a source file, its last_updated_ time is set to ``None``.\n\nThe default value for html_last_updated_fmt_ is changed\nfrom ``None`` to the empty string.\n\nUsage\n    #. Install the Python package ``sphinx-last-updated-by-git``\n    #. Add ``'sphinx_last_updated_by_git'`` to ``extensions`` in your ``conf.py``\n    #. Run Sphinx!\n\nOptions\n    * If a source file is not tracked by Git (e.g. because it has been\n      auto-generated on demand by autosummary_generate_) but its dependencies\n      are, the last_updated_ time is taken from them.  If you don't want this\n      to happen, use ``git_untracked_check_dependencies = False``.\n\n    * If a source file is not tracked by Git, its HTML page doesn't get a\n      source link.  If you do want those pages to have a sourcelink, set\n      ``git_untracked_show_sourcelink = True``.  Of course, in this case\n      html_copy_source_ and html_show_sourcelink_ must also be ``True``, and\n      the theme you are using must support source links in the first place.\n\n    * By default, timestamps are displayed using the local time zone.\n      You can specify a datetime.timezone_ object (or any ``tzinfo`` subclass\n      instance) with the configuration option ``git_last_updated_timezone``.\n      You can also use any string recognized by babel_,\n      e.g. ``git_last_updated_timezone = 'Pacific/Auckland'``.\n\n    * By default, the \"last updated\" timestamp is added as an HTML ``<meta>``\n      tag.  This can be disabled by setting the configuration option\n      ``git_last_updated_metatags`` to ``False``.\n\n    * Files can be excluded from the last updated date calculation by passing\n      a list of exclusion patterns to the configuration option\n      ``git_exclude_patterns``.\n      These patterns are checked on both source files and dependencies\n      and are treated the same way as Sphinx's exclude_patterns_.\n\n    * Individual commits can be excluded from the last updated date\n      calculation by passing a list of commit hashes to the configuration\n      option ``git_exclude_commits``.\n\nCaveats\n    * When using a \"Git shallow clone\" (with the ``--depth`` option),\n      the \"last updated\" commit for a long-unchanged file\n      might not have been checked out.\n      In this case, the last_updated_ time is set to ``None``\n      (and a warning is shown during the build).\n\n      This might happen on https://readthedocs.org/\n      because they use shallow clones by default.\n      To avoid this problem, you can edit your config file ``.readthedocs.yml``:\n\n      .. code:: yaml\n\n          version: 2\n          build:\n            os: \"ubuntu-22.04\"\n            tools:\n              python: \"3\"\n            jobs:\n              post_checkout:\n                - git fetch --unshallow || true\n\n      For more details, `read the docs`__.\n\n      __ https://docs.readthedocs.io/en/latest/build-customization.html#unshallow-git-clone\n\n      This might also happen when using Github Actions,\n      because `actions/checkout`__ also uses shallow clones by default.\n      This can be changed by using ``fetch-depth: 0``:\n\n      .. code:: yaml\n\n          steps:\n            - uses: actions/checkout@v3\n              with:\n                fetch-depth: 0\n\n      __ https://github.com/actions/checkout\n\n      If you only want to get rid of the warning (without actually fixing the problem),\n      use this in your ``conf.py``::\n\n          suppress_warnings = ['git.too_shallow']\n\n    * When a project on https://readthedocs.org/ using their default theme\n      ``sphinx_rtd_theme`` was created before October 20th 2020,\n      the date will not be displayed in the footer.\n\n      One work-around is to enable the (undocumented) `feature flag`_\n      ``USE_SPHINX_LATEST``.\n\n      Another work-around is to override the defaults\n      by means of a ``requirements.txt`` file containing something like this::\n\n          sphinx>=2\n          sphinx_rtd_theme>=0.5\n\n      See also `issue #1`_.\n\n    * In Sphinx versions 5.0 and 5.1, there has been\n      a regression in how dependencies are determined.\n      This could lead to spurious dependencies\n      which means that some \"last changed\" dates were wrong.\n      This has been fixed in Sphinx version 5.2 and above.\n\n      See also `issue #40`_.\n\nLicense\n    BSD-2-Clause (same as Sphinx itself),\n    for more information take a look at the ``LICENSE`` file.\n\nSimilar stuff\n    | https://github.com/jdillard/sphinx-gitstamp\n    | https://github.com/OddBloke/sphinx-git\n    | https://github.com/MestreLion/git-tools (``git-restore-mtime``)\n    | https://github.com/TYPO3-Documentation/sphinxcontrib-gitloginfo\n\n.. _Sphinx: https://www.sphinx-doc.org/\n.. _last_updated: https://www.sphinx-doc.org/en/master/\n    templating.html#last_updated\n.. _exclude_patterns: https://www.sphinx-doc.org/en/master/usage/\n    configuration.html#confval-exclude_patterns\n.. _autosummary_generate: https://www.sphinx-doc.org/en/master/\n    usage/extensions/autosummary.html#confval-autosummary_generate\n.. _html_copy_source: https://www.sphinx-doc.org/en/master/\n    usage/configuration.html#confval-html_copy_source\n.. _html_show_sourcelink: https://www.sphinx-doc.org/en/master/\n    usage/configuration.html#confval-html_show_sourcelink\n.. _html_last_updated_fmt: https://www.sphinx-doc.org/en/master/\n    usage/configuration.html#confval-html_last_updated_fmt\n.. _datetime.timezone: https://docs.python.org/3/library/\n    datetime.html#timezone-objects\n.. _babel: https://babel.pocoo.org/\n.. _feature flag: https://docs.readthedocs.io/en/latest/\n    guides/feature-flags.html\n.. _issue #1: https://github.com/mgeier/sphinx-last-updated-by-git/issues/1\n.. _issue #40: https://github.com/mgeier/sphinx-last-updated-by-git/issues/40\n",
    "bugtrack_url": null,
    "license": "BSD-2-Clause",
    "summary": "Get the \"last updated\" time for each Sphinx page from Git",
    "version": "0.3.7",
    "project_urls": {
        "Homepage": "https://github.com/mgeier/sphinx-last-updated-by-git/"
    },
    "split_keywords": [
        "sphinx",
        " git"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "63a57dbfd5662d90de2d2c8694ee3c1f4b337be0d6ae05850b738daacfeb9aeb",
                "md5": "fb6383740d4c4f0cad2de44b0a044fe3",
                "sha256": "9937f235911aaec566a652b26952b29f530abb86f98e0fb67843227301636457"
            },
            "downloads": -1,
            "filename": "sphinx_last_updated_by_git-0.3.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "fb6383740d4c4f0cad2de44b0a044fe3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8464,
            "upload_time": "2024-05-04T15:52:53",
            "upload_time_iso_8601": "2024-05-04T15:52:53.489903Z",
            "url": "https://files.pythonhosted.org/packages/63/a5/7dbfd5662d90de2d2c8694ee3c1f4b337be0d6ae05850b738daacfeb9aeb/sphinx_last_updated_by_git-0.3.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0e7262832f58170e132f5cc546bc6fb260d7651d244e3ae4606e8aba3e109ba",
                "md5": "c4127293a3ed1da28406c2ab8c2b8947",
                "sha256": "edfd4970d9778123d3d0d9c5c9a9e3d700867a080539eb2bfe01e7078ca1dc78"
            },
            "downloads": -1,
            "filename": "sphinx_last_updated_by_git-0.3.7.tar.gz",
            "has_sig": false,
            "md5_digest": "c4127293a3ed1da28406c2ab8c2b8947",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 10668,
            "upload_time": "2024-05-04T15:52:54",
            "upload_time_iso_8601": "2024-05-04T15:52:54.585128Z",
            "url": "https://files.pythonhosted.org/packages/f0/e7/262832f58170e132f5cc546bc6fb260d7651d244e3ae4606e8aba3e109ba/sphinx_last_updated_by_git-0.3.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-04 15:52:54",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mgeier",
    "github_project": "sphinx-last-updated-by-git",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "sphinx-last-updated-by-git"
}
        
Elapsed time: 0.25141s