napoleon
napoleon copied to clipboard
Custom sections cannot be used with class docstrings
I have a class doc-string for which I want to include a custom section. When I include my custom section in napoleon_custom_section
it works fine for functions and methods, but not for the class itself. Instead I get a warning and the section header is removed.
For example:
class Example():
"""
An example class
Programming Notes
-----------------
This is my custom section that I would like to show in my class doc-string.
"""
In my conf.py
I have the following line:
napoleon_custom_sections = ['Programming Notes']
The best behavior would be for custom sections to also work for classes. An acceptable temporary fix would be for the unknown section title to just be passed through and displayed in some emphasized way rather than being removed.
Related Issue: #2
This would be very desirable since classes can have class variables (e.g. pyqt
signals and slots) that should be documented! Currently, a docstring directly below the class
signature or within the __init__
function (if defined) both apply to the __init__
function and the Sphinx documentation says not to mix-and-match this documentation style (see class ExampleClass
in the Google Style Docstrings Example).
For additional reference, please see this SO question. Simply using an Attributes
header does not distinguish between instance vs. class attributes/variables, so I would like to be able to change the header to Class Variables
or Class Attributes
.