Child Class __init__ Inherit Arguments of Parent Class __init__

179 views
Skip to first unread message

Connor McClellan

unread,
Mar 3, 2020, 1:25:20 PM3/3/20
to sphinx-users
I have been trying to use Sphinx-autodoc to have my child classes __init__ inherit the arguments of their parent classes __init__.  This would essentially replace the *args argument in the child docstring with the arguments of the parent.

Python code:

class Parent(object):

   
def __init__(self, parent_argument):
     
"""
      Parent class
      Args:
          parent_argument (int): Argument of the parent.
      """

     
self.arg1 = parent_argument


class Child(Parent):

   
def __init__(self, child_argument, *args):
       
"""
        Child class
        Args:
            child_argument (int): Argument of the child
            *args:
        """

       
super().__init__(*args)
       
self.arg2 = child_argument

and the resulting docs would like this:


Is this currently possible with autodoc?

Thanks,
Connor

Komiya Takeshi

unread,
Mar 4, 2020, 12:13:45 PM3/4/20
to sphinx...@googlegroups.com
Hi,

autodoc does not support such feature. It is difficult to guess "*args" equals to "parent_argument". I'm welcome if you have good idea to realize it. contributions are always welcome :-)

Thanks,
Takeshi KOMIYA

2020年3月4日(水) 3:25 Connor McClellan <cmcclel...@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/e0b075a1-e979-40d4-8b2f-52daab5dff36%40googlegroups.com.

Connor McClellan

unread,
Mar 4, 2020, 12:59:34 PM3/4/20
to sphinx-users
Great thank you for the reply. I think this would be a great feature so I’ll think about ways to make it work.

Thanks,
Connor

Doctor Lab

unread,
Mar 4, 2020, 8:52:42 PM3/4/20
to sphinx-users
Reply all
Reply to author
Forward
0 new messages