我想出了一个猴子补丁functools.wraps
。因此,我只是将其添加到了conf.py
项目文档的sphinxsource
文件夹中的脚本中:
# Monkey-patch functools.wraps
import functools
def no_op_wraps(func):
"""Replaces functools.wraps in order to undo wrapping.
Can be used to preserve the decorated function's signature
in the documentation generated by Sphinx.
"""
def wrapper(decorator):
return func
return wrapper
functools.wraps = no_op_wraps
因此,当通过构建html页面时make html
,functools.wraps
此装饰器no_op_wraps
将替换它,该装饰器仅返回原始函数就什么也不做。