The Sphinx ‘autodoc’ extension expects to import the code modules, in order to generate API documentation.
The Sphinx configuration currently does not specify where to find the code modules for import. This means that when Make does not have the expected current directory (a normal occurrence), ‘autodoc’ complains:
/build/python-coverage-4.2+dfsg.1/doc/api_coverage.rst:13: WARNING: autodoc: failed to import class 'Coverage' from module 'coverage'; the following exception was raised: Traceback (most recent call last): File "/usr/lib/python3/dist-packages/sphinx/ext/autodoc.py", line 519, in import_object __import__(self.modname) ImportError: No module named 'coverage'
The resulting documentation has no content where the API documentation should be.
This can be fixed by:
Configuring Sphinx specifically to find the code modules, relative to the documentation directory. This will correct the above error, but does not address the more general assumption of current directory during the build process.
Detecting the current directory at Make time, and computing the directories needed for the various commands Make invokes.
The latter is the more robust and general solution. GNU Make sets the ‘CURDIR’ variable to the current working directory; this allows reliably computing relative paths for commands.
For your convenience, when GNU make starts (after it has processed any -C options) it sets the variable CURDIR to the pathname of the current working directory.