Skip to content

:undoc-members: option doesn't work for instance attributes #10193

Open

Description

@electric-coder

Describe the bug

The :undoc-members: option does not include instance attributes without docstrings when used with the .. autoclass:: directive.

How to Reproduce

example.py

class Example:
    """A simple example."""

    def __init__(self, one_arg: str = "value"):

        self.instance_var1 = 123
        self.instance_var2 = one_arg

example.rst

example
*******

.. autoclass:: example.Example
    :members:
    :undoc-members:

conf.py

import os
import sys
sys.path.insert(0, os.path.abspath(os.path.join('..', '..')))

html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']

extensions = [
    'sphinx.ext.autodoc',
    'sphinx_rtd_theme'
]

autoclass_content = 'class'
autodoc_class_signature = "mixed"
autodoc_typehints = 'signature'
autodoc_preserve_defaults = True
add_module_names = False
add_function_parentheses = True
autodoc_typehints_description_target="all"

Expected behavior

Instance attributes without docstrings should be included by autodoc in the documentation if the :undoc-members: option is specified.

Your project

Personal project

Screenshots

undoc_members

OS

Windows 10 Pro

Python version

3.9.0

Sphinx version

4.4.0

Sphinx extensions

autodoc

Extra tools

None

Additional context

No response

Activity

  1. added this to the some future version milestone on Sep 29, 2022
  2. electric-coder commented on Feb 1, 2024

    @electric-coder
    Author

    @picnixz can you tag this with the repository's autodoc label please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions