I have a class Foo that supports subscripting, so if foo is an instance of Foo, foo[12] will find the 12th one. Foo is defined something like this:
class Foo:
def __getitem__(self, i):
"""Get the ith element of self."""
....
The sphinx rst file looks something like this:
.. autoclass:: Foo
:members: __getitem__, ...
When sphinx builds the documentation, Foo's subscript-implementing __getitem__
member function is documented as:
__getitem__(i)
Get the ith element of the Foo.
But that function signature will be confusing to a reader of the documentation who does not know about Python dunder functions, and who does not know that subscripting brackets are defined with __getitem__
. It would be better to have __getitem__
documented like this:
foo[i]
Get the ith element of the Foo foo.
Is there a way to override the member function signature with foo[i]
, which does not look like a signature at all?