Skip to content

Commit

Permalink
Support "source-read" being emitted for included docs
Browse files Browse the repository at this point in the history
Since Sphinx 7.2, the "source-read" event is emitted for included
documents (.. include directive). A document can be included multiple
times, and thus the hook cannot assume that it's called only once per
docname.

An issue in Sphinx itself affects the extension when using included
documents. Add a warning in the README.
  • Loading branch information
lmoureaux committed Aug 25, 2023
1 parent f86285c commit 9d74e45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ Caveats

See also `issue #1`_.

* A regression in Sphinx version 7.2 prevents the extension from working
properly when using the `.. include` directive. See `Sphinx issue
#11643`_.

* In Sphinx versions 5.0 and 5.1, there has been
a regression in how dependencies are determined.
This could lead to spurious dependencies
Expand Down Expand Up @@ -117,3 +121,4 @@ Similar stuff
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
.. _Sphinx issue #11643: https://github.com/sphinx-doc/sphinx/issues/11643
6 changes: 4 additions & 2 deletions src/sphinx_last_updated_by_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,10 @@ def _builder_inited(app):

def _source_read(app, docname, source):
env = app.env
assert docname not in env.git_last_updated
env.git_last_updated[docname] = None
# Since Sphinx 7.2, the source-read hook can be called multiple times
# when using .. include
if docname not in env.git_last_updated:
env.git_last_updated[docname] = None


def _env_merge_info(app, env, docnames, other):
Expand Down

0 comments on commit 9d74e45

Please sign in to comment.