Regression in dependencies (e.g. using autodoc/autosummary)
mgeier opened this issue · 5 comments
Describe the bug
Recently, the unit tests of my project https://github.com/mgeier/sphinx-last-updated-by-git started to fail because Sphinx has changed the way how some dependencies of source files are determined.
I don't know whether this is intentional or an unwanted regression! [UPDATE: given the example below (#10692 (comment)), it seems to be a bug]
How to Reproduce
$ git clone https://github.com/mgeier/test-repo-for-sphinx-last-updated-by-git.git
$ cd test-repo-for-sphinx-last-updated-by-git
Open conf.py
and remove the line with 'sphinx_last_updated_by_git'
.
Add this to conf.py
:
def _env_updated(app, env):
print(env.dependencies['index'])
exit()
def setup(app):
app.connect('env-updated', _env_updated)
If you want to see the HTML output, you should also remove this line (and the exit()
above):
templates_path = ['_templates']
After all those changes, run Sphinx:
$ python3 -m sphinx . _build -E
The last line of output will show the dependencies of index.rst
:
{'example_module.py'}
Expected behavior
With Sphinx 4.5.0 and before, there were no dependencies:
set()
Your project
https://github.com/mgeier/test-repo-for-sphinx-last-updated-by-git
Sphinx version
Sphinx extensions
sphinx.ext.autosummary
Additional context
I've bisected the change to commit ab3b3e2, which is part of #10337, created by @AA-Turner.
I also found out this change using sphinx-last-updated-by-git
extension.
Sphinx 4.5.0
docname: genindex, deps: set()
docname: glossaire, deps: set()
docname: index, deps: {'_templates/license.txt'}
docname: info/espace-personnel, deps: set()
docname: info/general, deps: set()
docname: info/index, deps: set()
docname: interne/aliases, deps: set()
docname: interne/index, deps: set()
docname: interne/meta-doc, deps: set()
docname: services/drive, deps: set()
docname: services/email, deps: set()
docname: services/ftp, deps: set()
docname: services/git, deps: set()
docname: services/index, deps: set()
docname: services/rss, deps: set()
docname: services/sql, deps: set()
docname: services/ssh, deps: set()
docname: services/web, deps: set()
docname: services/webdav, deps: set()
docname: tutos/connexion-linux, deps: {'tutos/connexion-linux/dans_le_serveur.png', 'tutos/connexion-linux/se_connecter_au_serveur.png'}
docname: tutos/flux-rss, deps: {'tutos/flux-rss/capture_1.png', 'tutos/flux-rss/capture_6.png', 'tutos/flux-rss/capture_5.png', 'tutos/flux-rss/capture_2.png', 'tutos/flux-rss/capture_3.png', 'tutos/flux-rss/capture_4.png'}
docname: tutos/index, deps: set()
docname: tutos/mes-premiers-pas-sur-le-web, deps: {'tutos/mes-premiers-pas-sur-le-web/index.jpg', 'tutos/mes-premiers-pas-sur-le-web/screen_002.png', 'tutos/mes-premiers-pas-sur-le-web/screen_003.png'}
docname: tutos/webdav-android, deps: {'tutos/webdav-android/screen_003.png', 'tutos/webdav-android/screen_005.png', 'tutos/webdav-android/screen_006.png', 'tutos/webdav-android/screen_001.png', 'tutos/webdav-android/screen_002.png', 'tutos/webdav-android/screen_004.png', 'tutos/webdav-android/screen_007.png'}
Sphinx 5.1.1
docname: genindex, deps: set()
docname: glossaire, deps: set()
docname: index, deps: {'_templates/license.txt'}
docname: info/espace-personnel, deps: {'_templates/license.txt'}
docname: info/general, deps: {'_templates/license.txt'}
docname: info/index, deps: {'_templates/license.txt'}
docname: interne/aliases, deps: {'_templates/license.txt'}
docname: interne/index, deps: {'_templates/license.txt'}
docname: interne/meta-doc, deps: {'_templates/license.txt'}
docname: services/drive, deps: {'_templates/license.txt'}
docname: services/email, deps: {'_templates/license.txt'}
docname: services/ftp, deps: {'_templates/license.txt'}
docname: services/git, deps: {'_templates/license.txt'}
docname: services/index, deps: {'_templates/license.txt'}
docname: services/rss, deps: {'_templates/license.txt'}
docname: services/sql, deps: {'_templates/license.txt'}
docname: services/ssh, deps: {'_templates/license.txt'}
docname: services/web, deps: {'_templates/license.txt'}
docname: services/webdav, deps: {'_templates/license.txt'}
docname: tutos/connexion-linux, deps: {'tutos/connexion-linux/se_connecter_au_serveur.png', '_templates/license.txt', 'tutos/connexion-linux/dans_le_serveur.png'}
docname: tutos/flux-rss, deps: {'tutos/flux-rss/capture_2.png', 'tutos/flux-rss/capture_4.png', 'tutos/flux-rss/capture_5.png', 'tutos/flux-rss/capture_1.png', 'tutos/flux-rss/capture_6.png', '_templates/license.txt', 'tutos/flux-rss/capture_3.png'}
docname: tutos/index, deps: {'_templates/license.txt'}
docname: tutos/mes-premiers-pas-sur-le-web, deps: {'tutos/mes-premiers-pas-sur-le-web/screen_003.png', 'tutos/mes-premiers-pas-sur-le-web/screen_002.png', '_templates/license.txt', 'tutos/mes-premiers-pas-sur-le-web/index.jpg'}
docname: tutos/webdav-android, deps: {'tutos/webdav-android/screen_005.png', 'tutos/webdav-android/screen_006.png', 'tutos/webdav-android/screen_003.png', 'tutos/webdav-android/screen_002.png', 'tutos/webdav-android/screen_007.png', 'tutos/webdav-android/screen_004.png', 'tutos/webdav-android/screen_001.png', '_templates/license.txt'}
This seems like an error, as in my case _templates/license.txt
is only included in index
document with include
directive.
In Sphinx 4.5.0
only the index
document is noted as dependent of it, but with Sphinx 5.1.1
all children documents included with toctree
are also noted as dependent of it.
I dont think that it is the case, as only index
document will be affected if _templates/license.txt
changes.
Given the example from @n-peugnet, this indeed looks like an unintended regression.
@AA-Turner Do you have an idea what could have gone wrong in #10337?
Yes, thanks a lot, this fixes the unit tests in https://github.com/mgeier/sphinx-last-updated-by-git
@n-peugnet Can you check your example?
This fixed my example too:
Sphinx v5.1.1-87-g8db24515e
docname: genindex, deps: set()
docname: glossaire, deps: set()
docname: index, deps: {'_templates/license.txt'}
docname: info/espace-personnel, deps: set()
docname: info/general, deps: set()
docname: info/index, deps: set()
docname: interne/aliases, deps: set()
docname: interne/index, deps: set()
docname: interne/meta-doc, deps: set()
docname: services/drive, deps: {'services/drive/webdav_drive.png'}
docname: services/email, deps: set()
docname: services/ftp, deps: set()
docname: services/git, deps: set()
docname: services/index, deps: set()
docname: services/rss, deps: set()
docname: services/sql, deps: set()
docname: services/ssh, deps: set()
docname: services/web, deps: set()
docname: services/webdav, deps: set()
docname: tutos/connexion-linux, deps: {'tutos/connexion-linux/se_connecter_au_serveur.png', 'tutos/connexion-linux/dans_le_serveur.png'}
docname: tutos/flux-rss, deps: {'tutos/flux-rss/capture_3.png', 'tutos/flux-rss/capture_6.png', 'tutos/flux-rss/capture_5.png', 'tutos/flux-rss/capture_4.png', 'tutos/flux-rss/capture_1.png', 'tutos/flux-rss/capture_2.png'}
docname: tutos/index, deps: set()
docname: tutos/mes-premiers-pas-sur-le-web, deps: {'tutos/mes-premiers-pas-sur-le-web/screen_003.png', 'tutos/mes-premiers-pas-sur-le-web/screen_002.png', 'tutos/mes-premiers-pas-sur-le-web/index.jpg'}
docname: tutos/webdav-android, deps: {'tutos/webdav-android/screen_004.png', 'tutos/webdav-android/screen_003.png', 'tutos/webdav-android/screen_005.png', 'tutos/webdav-android/screen_002.png', 'tutos/webdav-android/screen_001.png', 'tutos/webdav-android/screen_007.png', 'tutos/webdav-android/screen_006.png'}