Skip to content
This repository has been archived by the owner on Apr 26, 2023. It is now read-only.

Custom sections cannot be used with class docstrings #33

Open
amicitas opened this issue Jul 10, 2021 · 3 comments
Open

Custom sections cannot be used with class docstrings #33

amicitas opened this issue Jul 10, 2021 · 3 comments

Comments

@amicitas
Copy link

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.

@amicitas
Copy link
Author

Related Issue: #2

@adam-grant-hendry
Copy link

adam-grant-hendry commented Feb 26, 2022

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).

@adam-grant-hendry
Copy link

adam-grant-hendry commented Feb 26, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants