我怎么能代替*args和**kwargs与装饰功能的文档中的真实签名?
假设我有以下装饰器和装饰功能:
import functools
def mywrapper(func):
@functools.wraps(func)
def new_func(*args, **kwargs):
print('Wrapping Ho!')
return func(*args, **kwargs)
return new_func
@mywrapper
def myfunc(foo=42, bar=43):
"""Obscure Addition
:param foo: bar!
:param bar: bla bla
:return: foo + bar
"""
return foo + bar
Run Code Online (Sandbox Code Playgroud)
因此,通话print(myfunc(3, 4))给我们:
Wrapping Ho!
7
Run Code Online (Sandbox Code Playgroud)
到现在为止还挺好.我还希望我的库包含myfunc与Sphinx一起正确记录的文件.但是,如果我通过以下方式将我的函数包含在我的sphinx html页面中:
.. automodule:: mymodule
:members: myfunc
Run Code Online (Sandbox Code Playgroud)
它实际上会显示为:
模糊的加法
我怎样才能摆脱myfunc(*args, **kwargs)标题中的泛型?这应该被myfunc替换(foo = …
python documentation decorator python-sphinx python-decorators
是否可以使用Sphinx autodoc从函数docstrings生成我的fabfile文档?
例如,对于包含setup_development我尝试过的任务的fabfile :
.. automodule::fabfile
:members:
.. autofunction:: setup_development
Run Code Online (Sandbox Code Playgroud)
但没有产生任何东西.
fabfile片段:
@task
def setup_development(remote='origin', branch='development'):
"""Setup your development environment.
* Checkout development branch & pull updates from remote
* Install required python packages
* Symlink development settings
* Sync and migrate database
* Build HTML Documentation and open in web browser
Args:
remote: Name of remote git repository. Default: 'origin'.
branch: Name of your development branch. Default: 'development'.
"""
<code>
Run Code Online (Sandbox Code Playgroud)