Autodoc documents private members of inner dataclass

270 views
Skip to first unread message

Alex Botev

unread,
Mar 30, 2022, 5:26:38 AM3/30/22
to sphinx-users
So I have something among the lines of:

```
class TopClass: 
    @my_decorator 
     class InternalClass: 
      """Persistent state.""" 
          a: int 
          b: int 
          c: int
```
Running autodoc correctly picks up InternalClass, but I get a lot of its private members documented, e.g.:
__dataclass_params__= _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False, frozen=False) __dict__= mappingproxy({'__module__': 'my_module.try', '__annotations__': {'a': 'int', 'b': 'int', 'c': 'int'}, '__doc__': 'Persistent state.', '__dict__': <attribute '__dict__' of 'InternalClass' objects>, '__weakref__': <attribute '__weakref__' of 'State' objects>, '__dataclass_params__': _DataclassParams(init=True,repr=True,eq=True,order=False,unsafe_hash=False,frozen=False), '__dataclass_fields__': {'a': Field(name='a',type='int',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'b': Field(name='b',type='int',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD), 'c': Field(name='c',type='int',default=<dataclasses._MISSING_TYPE object>,default_factory=<dataclasses._MISSING_TYPE object>,init=True,repr=True,hash=None,compare=True,metadata=mappingproxy({}),_field_type=_FIELD)}, '__init__': <function __create_fn__.<locals>.__init__>, '__repr__': <function __create_fn__.<locals>.__repr__>, '__eq__': <function __create_fn__.<locals>.__eq__>, '__hash__': None}) __eq__(other) Return self==value. __hash__= None __init__(a, b, c)

How can I prevent this?

Komiya Takeshi

unread,
Mar 30, 2022, 1:14:55 PM3/30/22
to sphinx...@googlegroups.com
Hi,

What option do you pass to the autodoc directives? Please show an
example of reST document.

Thanks,
Takeshi KOMIYA

2022年3月30日(水) 18:26 'Alex Botev' via sphinx-users
<sphinx...@googlegroups.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/2451dc5a-f3d8-43e0-a197-dc6afa8a34d9n%40googlegroups.com.

Alex Botev

unread,
Mar 30, 2022, 1:17:29 PM3/30/22
to sphinx...@googlegroups.com
So the reST document is literally:

.. currentmodule:: my_module

Standard API
============


MySection
---------

.. autosummary::

TopClass

TopClass
~~~~~~~~~

.. autoclass:: TopClass
:members:

Ibrar Ch

unread,
Mar 30, 2022, 1:35:54 PM3/30/22
to sphinx...@googlegroups.com
Message has been deleted

Alex Botev

unread,
Mar 31, 2022, 10:41:05 AM3/31/22
to sphinx...@googlegroups.com
Thanks a lot, submitted an issue here - https://github.com/sphinx-doc/sphinx/issues/10314

On Wed, Mar 30, 2022 at 7:28 PM Komiya Takeshi <i.tk...@gmail.com> wrote:
Hmm... that's strange. Could you post an issue to Sphinx repo with
reproducible project (including conf.py and python scripts), please?
Then I'll investigate it more.

Thanks,
Takeshi KOMIYA

2022年3月31日(木) 2:17 'Alex Botev' via sphinx-users


--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.

Alex Botev

unread,
Mar 31, 2022, 11:11:38 AM3/31/22
to sphinx...@googlegroups.com
Ah, this was a mistake. Apparently I have switched on the 'special-members': True, in the autodoc and forgot to exclude the corresponding members. Sorry for the confusion.

On Wed, Mar 30, 2022 at 7:28 PM Komiya Takeshi <i.tk...@gmail.com> wrote:
Hmm... that's strange. Could you post an issue to Sphinx repo with
reproducible project (including conf.py and python scripts), please?
Then I'll investigate it more.

Thanks,
Takeshi KOMIYA

2022年3月31日(木) 2:17 'Alex Botev' via sphinx-users


--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages