I am trying to use sphinx-doc: automodule: in combination with Mock-ed out modules in accordance with this answer. In particular, I use Mock to import PyQt5 modules that are not available in ReadTheDocs.
Strange, I believe that any class that inherits from the Mock-ed module class is not included in the final documentation. It seems that the sphinx dock cannot see them for some reason.
My slightly customizable layout looks like this:
from mock import Mock as MagicMock
class Mock(MagicMock):
__all__ = ['QApplication','pyqtSignal','pyqtSlot','QObject','QAbstractItemModel','QModelIndex','QTabWidget',
'QWebPage','QTableView','QWebView','QAbstractTableModel','Qt','QWidget','QPushButton','QDoubleSpinBox',
'QListWidget','QDialog','QSize','QTableWidget','QMainWindow','QTreeWidget',
'QAbstractItemDelegate','QColor','QGraphicsItemGroup','QGraphicsItem','QGraphicsPathItem',
'QGraphicsTextItem','QGraphicsRectItem','QGraphicsScene','QGraphicsView',]
def __init__(self, *args, **kwargs):
super(Mock, self).__init__()
@classmethod
def __getattr__(cls, name):
if name in ('__file__', '__path__'):
return os.devnull
else:
return Mock
@classmethod
def __setattr__(*args, **kwargs):
pass
def __setitem__(self, *args, **kwargs):
return
def __getitem__(self, *args, **kwargs):
return Mock
__all__You must enable style import from x import *for PyQt5 classes.
, object , , Mock ( ). :autoclass: , , Mock.