Autodoc: Dealing with __init__ modules

34 views
Skip to first unread message

F H

unread,
Mar 13, 2020, 12:02:37 PM3/13/20
to sphinx-users
Hi,

I am documenting a Python package with the autodoc extension, using the automodule directive. My package contains three sub-packages and four __init__ modules, which all contain functions and attributes to be documented. My problem is that when I automodule these __init__ modules, all functions are listed as some_package.__init__.some_function(). But I would like them to be displayed as some_package.some_function() instead.

I have modified the __module__ and __qualname__ attribute of the object provided by the event autodoc-process-signature , removing these parts, but that seems to have no impact on the generated signature. So my question is: How do I modify the fully qualified name of a signature?

Cheers,
Ferdinand

Komiya Takeshi

unread,
Mar 13, 2020, 11:47:14 PM3/13/20
to sphinx...@googlegroups.com
Hi Ferdinand,

How did you use automodule directive? Please remove "__init__" from
its argument if you gave module name containing __init__ like
"some_package.__init__". automodule takes a module name as your python
script does. So no __init__ is needed for its argument.

If not, please let me know how did you use autodoc in detail (reST
document, conf.py, the structure of your libraries and so on).

Thanks,
Takeshi KOMIYA

2020年3月14日(土) 1:02 F H <bee...@gmail.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/98c45484-d352-46d7-9c64-afe24fd2ba36%40googlegroups.com.

F H

unread,
Mar 15, 2020, 6:36:55 AM3/15/20
to sphinx-users
Hi,

thank you for the quick answer. It seems so obvious now, but that did the trick.

Cheers,
Ferdinand


Am Samstag, 14. März 2020 04:47:14 UTC+1 schrieb Komiya Takeshi:
Hi Ferdinand,

How did you use automodule directive? Please remove "__init__" from
its argument if you gave module name containing __init__ like
"some_package.__init__". automodule takes a module name as your python
script does. So no __init__ is needed for its argument.

If not, please let me know how did you use autodoc in detail (reST
document, conf.py, the structure of your libraries and so on).

Thanks,
Takeshi KOMIYA

2020年3月14日(土) 1:02 F H <bee...@gmail.com>:
>
> Hi,
>
> I am documenting a Python package with the autodoc extension, using the automodule directive. My package contains three sub-packages and four __init__ modules, which all contain functions and attributes to be documented. My problem is that when I automodule these __init__ modules, all functions are listed as some_package.__init__.some_function(). But I would like them to be displayed as some_package.some_function() instead.
>
> I have modified the __module__ and __qualname__ attribute of the object provided by the event autodoc-process-signature , removing these parts, but that seems to have no impact on the generated signature. So my question is: How do I modify the fully qualified name of a signature?
>
> Cheers,
> Ferdinand
>
> --
> 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...@googlegroups.com.

Somsak Anuson

unread,
Mar 15, 2020, 7:04:07 AM3/15/20
to sphinx...@googlegroups.com

ในวันที่ ศ. 13 มี.ค. 2020 23:02 F H <bee...@gmail.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.
Reply all
Reply to author
Forward
0 new messages