Hi,
I've currently switched to mkdocs and I have have to say that this is an amazing project :)
But there are a few minor issues I did not manage to resolve on my own. I am using a simple self-written decorator from decorit which copies the Parameters
section from a function to another. The function looks like the following:
def copy_doc_params(source: Callable) -> Callable:
"""Copy parameters from docstring source."""
@beartype
def wrapper_copy_doc(func: Callable) -> Callable:
PARAMS_STRING = 'Parameters'
doc_source = source.__doc__
doc_func = func.__doc__
if doc_source and doc_func and doc_source.find(PARAMS_STRING) != -1:
# find last \n before keyphrase
idx = doc_source[:doc_source.find(PARAMS_STRING)].rfind('\n')
doc_params = doc_source[idx:]
doc_params = doc_source[doc_source.find(PARAMS_STRING):]
func.__doc__ = '{0}\n\n{1}'.format( # noqa: WPS125
doc_func.rstrip(), # ensure that doc_func ends on empty line
doc_params,
)
return func
return wrapper_copy_doc
def func(a):
"""Function func.
Parameters
-----------------
a : int
Variable with name a.
"""
pass
@copy_docs_params(func)
def gunc(a):
"""Function gunc."""
pass
print(func.__name__, func.__doc__)
print(gunc.__name__, gunc.__doc__)
Printing the names, the docstring is copied as expected. But using it with mkdocs, it shows me only the original docstring of gunc
. Including functools.wrap
did not change the result.
Thank you for your help.
Best, Daniel
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too