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
sphinx.util.get_module_source fails for builtins #5614
Labels
Milestone
Comments
Chilipp
added a commit
to psyplot/psy-simple
that referenced
this issue
Nov 11, 2018
simple hack to prevent sphinx-doc/sphinx#5614
Chilipp
added a commit
to psyplot/psy-maps
that referenced
this issue
Nov 11, 2018
simple hack to prevent sphinx-doc/sphinx#5614
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Nov 12, 2018
…n modules are imported
tk0miya
added a commit
to tk0miya/sphinx
that referenced
this issue
Nov 12, 2018
…n modules are imported
tk0miya
added a commit
that referenced
this issue
Nov 13, 2018
Fix #5614: autodoc: incremental build is broken when builtin modules …
Fixed by #5619. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Subject: Importing from builtins (or itertools) forces the module file to be marked as changed
Problem
Importing itertools or builtins in a module will always mark this module to be changed when using the
BuildEnvironment.get_outdated_files
method. This then always triggers a rebuilt of the module, slowing down the build.Procedure to reproduce the problem
Quick demonstration or the bug source
The source of the problem lies in sphinx.util.get_module_source, you can run
which essentially is because builtins (and itertools) do not have an associated
__file__
attribute, but a__loader__
, and you getThe problem here is, that
get_module_source
returns'string'
.Example project
To see the result of this, consider the following small project. We create a documentation of the
conf.py
module using theautomodule
directive:conf.py
contents.rst
and build it with
Error logs / results
The first build goes fine, and 1 source file is added.
The second build marks one file as changed.
It says
updating environment: [] 0 added, 1 changed, 0 removed
(which is clearly wrong since none of the files has been changed). For larger projects however, this means that this the documented module is always rebuilt which slows down the built process.I traced the problem down:
AutodocDirective
generates a ModuleDocumenter (see AutodocDirective.run)ModuleAnalyzer
usesget_module_source
to investigateitertools
(see ModuleAnalyzer.for_module)'string'
byget_module_source
(see sphinx.util.get_module_source), thefilename_set
get's a'<string>'
addedAutodocDirective
adds this to the dependencies in (see AutodocDirective.run)get_outdated_files
method of theBuildEnvironment
then looks for a file name calledpath.join(self.srcdir, '<string>')
(see BuildEnvironment.get_outdated_files) which is clearly not existing and hence marks the original module (conf.py
) as changed.Expected results
The builtins module has to be better handled when it comes to the dependencies in a module.
Reproducible project / your project
(see the
conf.py
andcontents.rst
shown above)example.zip
Environment info
The text was updated successfully, but these errors were encountered: