【发布时间】:2016-03-29 12:06:47
【问题描述】:
我目前正在通过 read-the-docs 在线获取我的代码文档,但是,让 read-the-docs 处理我的 PyQt4 依赖模块似乎有问题。
我的项目结构如下:
pkg
pkg/__init__.py
pkg/modules/
pkg/modules/__init__.py
pkg/modules/somemodules.py
pkg/gui/__init__.py
pkg/gui/someGUImodules.py
我正在使用 sphinx-autodoc 来构建不同模块的文档字符串的 html 表示。但是,在我的本地机器上一切正常,因为我需要在阅读文档时使用mock PyQt4,我遇到了以下问题:在我的一个 GUI 类中,我通过子类化 QtGui.QDialog
class listSelectorDialog(QtGui.QDialog):
def __init__(self,parent,List):
super(listSelectorDialog,self).__init__(parent)
和listSelectorDialog通过
class advancedListSelectorDialog(listSelectorDialog):
def __init__(self,parent,List):
super(advancedListSelectorDialog,self).__init__(parent,List)
Mocking QtGui 会导致 read-the-docs 告诉我:
class advancedListSelectorDialog(listSelectorDialog):
TypeError: Error when calling the metaclass bases
str() takes at most 1 argument (3 given)
因此崩溃。我试图通过选择将我的包构建到虚拟环境中
使用 setup.py install 在 virtualenv 中安装您的项目
然而,事实证明,即使 PyQt4 在 pip 中列出,您也无法安装它,请参阅 https://superuser.com/questions/679298/how-to-install-pyqt4-and-what-are-the-practical-differences-between-pyqt4-and-py。
到目前为止,我发现的唯一解决方法是,如果环境是 RTD,则不加载 GUI 模块并省略 GUI 模块的文档,但这不应该是最终解决方案。谢谢。
【问题讨论】:
-
在尝试继承 Qt 模块时出现完全相同的问题 - 成功了吗?
-
不幸的是,决定暂时不记录 GUI 模块。当我有一些额外的时间时,我会试着弄清楚。
标签: python-2.7 pyqt4 python-sphinx read-the-docs