问题
I'm writing a package that wraps PyQt5 functionality and trying to put the documentation on readthedocs. Since PyQt5 is an extension module I mock the module and its classes (manually, because using unittest.mock causes metaclass conflicts):
class PyQt5:
class QtCore:
@staticmethod
def qVersion():
return '5.0.0'
class QObject:
pass
# etc
sys.modules['PyQt5'] = PyQt5
This works fine locally. But although the builds pass without error on readthedocs, there is no autodoc output. What am I missing ?
The project on BitBucket: https://bitbucket.org/fraca7/qtypy/
On ReadTheDocs: https://readthedocs.org/projects/qtypy/
回答1:
Despite it "passing" the build, if you look carefully at your logs, you will see there are errors like ImportError: No module named 'qtypy'
when it starts invoking sphinx.
When I've done this successfully in the past, I've always had a setup.py
file at the top level of the repository for installing the package, which I believe is the only way that readthedocs can install the package.
I've then enabled, on readthedocs project admin -> advanced settings,
Install your project inside a virtualenv using setup.py install"
This ensures your module is available to be imported when sphinx runs, so that it can automatically generate the documentation (provided you have successfully mocked PyQt5).
来源:https://stackoverflow.com/questions/48356987/autodoc-on-readthedocs-and-pyqt5