假设我有以下以Numpydoc 样式记录的函数,并且文档是使用Sphinx autofunction 指令自动生成的:
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
我不想将隐藏的参数宣传为我的公共 API 的一部分,但它会显示在我的自动生成的文档中。有什么方法可以告诉 Sphinx 忽略函数的特定参数,或者(甚至更好)使其自动忽略带前导下划线的参数?