autodoc on readthedocs and PyQt5

回眸只為那壹抹淺笑 提交于 2019-12-11 06:04:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!