Suppose I have the following function that is documented in the Numpydoc style, and the documentation is auto-generated with the Sphinx autofunction directive:
def foo(x, y, _hidden_argument=None):
"""
Foo a bar.
Parameters
----------
x: str
The first argument to foo.
y: str
The second argument to foo.
Returns
-------
The barred foo.
"""
if _hidden_argument:
_end_users_shouldnt_call_this_function(x, y)
return x + y
I don't want to advertise the hidden argument as part of my public API, but it shows up in my auto-generated documentation. Is there any way to tell Sphinx to ignore a specific argument to a function, or (even better) make it auto-ignore arguments with a leading underscore?
I don't think there is an option for that in Sphinx. One possible way to accomplish this without having to hack into the code, is to use customized signature.
In this case, you need something like:
.. autofunction:: some_module.foo(x, y)
This will override the parameter list of the function and hide the unwanted argument in the doc.