Unable to override automodule option “undoc-members” for a single class in the module

179 views
Skip to first unread message

Yashaswi Kashyap

unread,
Aug 7, 2019, 10:26:35 AM8/7/19
to sphinx-users

I have a class that inherits from ctypes.Structure defined with the _fields_ attribute.

I have the sphinx autodoc running on a whole folder of modules, with AUTODOC_DEFAULT_OPTIONS containing "undoc-members".

As far as I have read, "undoc-members" generates documentation for classes where docstrings have not been provided. This is majorly useful for the project i am working on. But I need to make an exception in one case.

For the class that inherits ctypes.Structure, I want to override the autodocumentation of the attributes in the class, and i want the docstring provided in the class to apply in the documentation generated. But I am unable to do this. undoc-members also documents members which have docstrings provided in my present example of the class inherited from ctypes.Structure.

What I already tried:


.. automodule:: root.analyzers.rs232.Analyzer1
   :members:
   :undoc-members:
   :show-inheritance:
   .. autoclass:: Analyzer1.DebugSetup.SetupFields
      :no-undoc-members:

.. automodule:: root.analyzers.rs232.Analyzer1
   :members:
   :undoc-members:
   :show-inheritance:
   :exclude-members: DebugSetup.SetupFields

None of these work. The concern here is, i want to retain :undoc-members: for most of the classes in the module except for some (2 in my case) of them.

I am not familiar with event handling with sphinx autodoc. From what i have read, the only solution seems to be to write an event handler for when the object of interest (class in this case) is parsed, and then we can override the default options during the parsing or processing of the docstring for the given class.

So my expectation is that I need to override the default documentation of the class (that inherits from ctypes.Structure) and for the engine to take the documentation i have provided in the docstring for the class.


Reply all
Reply to author
Forward
0 new messages