Sphinx - autodoc a class extending a mocked module

56 views
Skip to first unread message

johan Borgström

unread,
Nov 13, 2017, 12:01:40 PM11/13/17
to Python Programming for Autodesk Maya
Hi,

I am testing Sphinx and the autodoc feature. It seems like no documentation is generated when a class is extending a mocked module. (In my conf.py i am using autodoc_mock_imports = ['pymel', 'pyside2'])

Does anyone have any tips for generating docs for mocked modules?

Best,
Johan

Justin Israel

unread,
Nov 13, 2017, 1:26:35 PM11/13/17
to python_in...@googlegroups.com
I've seen the same behaviour when I mock objects, but I usually do that because they aren't available during the doc gen process and they aren't objects I would want included in my docs anyways. 
I'm curious, what kind of objects would you need to mock but also want to document? If they are mocked it implies they aren't available, which means neither are the docstrings or signatures of those objects. 


Best,
Johan

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/fea21276-740f-4a55-849b-c9ec1efcd222%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

johan Borgström

unread,
Nov 14, 2017, 8:32:00 AM11/14/17
to Python Programming for Autodesk Maya
Hi Justin,

I am building a custom model and the class is extending QtCore.QObject
The reason I extend QObject is to be able to emit a signal. In this case it can probably be done with composition instead of inheritance. But in some other cases I am extending PySide classes and I would like to keep it this way. So I want to document "my implementation" of the PySide classes, can I do this? 

Best,
Johan

On Monday, November 13, 2017 at 7:26:35 PM UTC+1, Justin Israel wrote:


On Tue, Nov 14, 2017, 6:01 AM johan Borgström <jo...@petfactory.se> wrote:
Hi,

I am testing Sphinx and the autodoc feature. It seems like no documentation is generated when a class is extending a mocked module. (In my conf.py i am using autodoc_mock_imports = ['pymel', 'pyside2'])

Does anyone have any tips for generating docs for mocked modules?

I've seen the same behaviour when I mock objects, but I usually do that because they aren't available during the doc gen process and they aren't objects I would want included in my docs anyways. 
I'm curious, what kind of objects would you need to mock but also want to document? If they are mocked it implies they aren't available, which means neither are the docstrings or signatures of those objects. 


Best,
Johan

--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_maya+unsub...@googlegroups.com.

johan Borgström

unread,
Nov 19, 2017, 3:54:12 PM11/19/17
to Python Programming for Autodesk Maya
Instead of using the "autodoc_mock_imports" in the conf.py I "manually mocked" the PySide classes. Now the documentation is generating for classes that extends the PySide.

import mock
sys.modules['PySide2'] = mock.Mock(QtWidgets=object)

One downside to this is that the base class will be object if we use :show-inheritance: in the .rst files. 

// Johan
Reply all
Reply to author
Forward
0 new messages