Python: Override super-class docstring without function re-implementation #637
Replies: 2 comments
-
+1. Having an example on how to handle this would be great. This is a common design pattern to handle programmatically adding documentation to |
Beta Was this translation helpful? Give feedback.
-
Hello, thanks for the discussion/idea. This is achievable with a Griffe extension. The extension would visit and handle attribute assignments (statements of the form |
Beta Was this translation helpful? Give feedback.
-
I have a use-case where I have a generic super-class which provides standard functionality to all sub-classes. I would like the ability to overwrite the docstring for the super-class' functions in the subclass so they're more reflective of the sub-class.
If I were to generate the docs for the
Sub
class withinherited_members: true
, I would see theSuper
docstring for__init__
as theSub
docstring for__init__
,Super
docstring for__eq__
as theSub
docstring for__eq__
, as well as theSuper
docstring forcreate_random
as theSub
docstring forcreate_random
.I would like to be able to add the following lines to the bottom of my file, and mkdocstrings would detect the overwritten docstrings and update the
Sub
docstrings accordingly.If a better way could be found to overwrite the parent docstrings, then that would be sufficient.
Beta Was this translation helpful? Give feedback.
All reactions