I searched and searched for a solution where I can use Sphinx autodoc
to find all the decorator wrapped functions in my Python script/file. The script contains a number of functions all called step_impl
with different parameters, but each wrapped by a different unique decorator. I want to be able to document these as separate functions. Currently it is only picking the last function in the script.
Here is what the script looks like:
@given(u'I am testing a browser')
def step_impl(context):
"""STEP: I am testing a browser
:param context: webdriver context
:type context: dictionary
"""
<stuff here>
@when(u'I visit "{browser_page}"')
def step_impl(context, browser_page):
<other stuff here>
@then(u'I see the Top Rail')
def step_impl(context):
context.page.assert_element_display("id", "adv_header")
<still other stuff here>
So I have the .rst
file with the automodule
formatting:
.. automodule:: features.steps.general
:members:
:undoc-members:
:show-inheritance:
And the documentation only lists one function as:
features.steps.general.step_impl(context, title_text, element_type, element_name)
which happens to be the last function in the script.
How can I have the decorator listed for each function and list all functions even if they have the same name. I tried to understand functools.wraps
, but couldn't get my head 'wrapped' around it (see what I did there!!).
Thank you for any guidance in advance....