Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only check source files that are in "found_docs" #60

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ jobs:
python tests/update_submodules.py
- name: Install Python package
env:
# See https://github.com/pypa/wheel/issues/507:
PYTHONWARNINGS: error,ignore:pkg_resources is deprecated:DeprecationWarning
PYTHONWARNINGS: error,default::DeprecationWarning
run: |
python -m pip install .
- name: Install test dependencies
env:
PYTHONWARNINGS: error,default::DeprecationWarning
run: |
python -m pip install -r tests/requirements.txt
- name: Run pytest
Expand Down
5 changes: 5 additions & 0 deletions src/sphinx_last_updated_by_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ def _builder_inited(app):

def _source_read(app, docname, source):
env = app.env
if docname not in env.found_docs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work in my case when sphinx-build is called from the documentation root. The issue is that the included file is also used as a main document in the toctree. So for in-source builds, _source_read gets called as follows:

_source_read(app, "including-doc", ...)  # The doc with the include
_source_read(app, "included-doc", ...)  # From include
_source_read(app, "included-doc", ...)  # As main document

When running sphinx-build from a different location, we get:

_source_read(app, "including-doc", ...)  # The doc with the include
_source_read(app, "path/to/included-doc", ...)  # From include
_source_read(app, "included-doc", ...)  # As main document

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, OK, so there are still duplicates ...

I combined your #57 and my #60 in #61, does that work?

# Since Sphinx 7.2, "docname" can be None or a relative path
# to a file included with the "include" directive.
# We are only interested in actual source documents.
return
assert docname not in env.git_last_updated
env.git_last_updated[docname] = None

Expand Down