How can I replace *args
and **kwargs
with the real signature in the documentation of decorated functions?
Let\'s say I have the following d
I came up with a monkey-patch for functools.wraps
.
Accordingly, I simply added this to the conf.py
script in my project documentation's sphinx source
folder:
# 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
Hence, when building the html page via make html
, functools.wraps
is replaced with this decorator no_op_wraps
that does absolutely nothing but simply return the original function.