-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
I have an API library with a single class containing methods for accessing various object types in the API. Each function is prefixed with its object type, like so:
class MyApiClass:
"""Example API class."""
# Foo
def foo_get(self, id: int):
# ...
pass
def foo_search(self, query: str):
# ...
pass
def foo_barize(self, foo: ...):
# ...
pass
# Bar
def bar_get(self, id: int):
# ...
pass
def bar_search(self, query: str):
# ...
pass
def bar_bazify(self, bar: ...):
# ...
pass
I want to document each supported object type separately, with a separate header and description, and have all of the relevant functions grouped together. Right now, to do this, I'd have to specify every function manually:
Foo
----------
Foo description goes here.
.. autofunction:: MyApiClass.foo_get
.. autofunction:: MyApiClass.foo_search
.. autofunction:: MyApiClass.foo_barize
Bar
----------
Bar description goes here.
.. autofunction:: MyApiClass.bar_get
.. autofunction:: MyApiClass.bar_search
.. autofunction:: MyApiClass.bar_bazify
However, this means that I have to manually update the docs every time I add a new function. It would be nice if instead we could use a glob:
Foo
----------
Foo description goes here.
.. autofunction:: MyApiClass.foo_*
Bar
----------
Bar description goes here.
.. autofunction:: MyApiClass.bar_*
Describe alternatives you've considered
This could be done with some sort of automatic generator that runs before the docs are built and automatically writes out the autofunction
directives.
Alternatively, a new directive could be introduced specifically to support globbing/more advanced matches (regex?).
I'm not aware of any plugins that do this (at least, I haven't found any in my limited search), hence this feature request.