"Dynamically" Modified Docstrings Are Not Rendered
lovetheguitar opened this issue · comments
lovetheguitar commented
Problem Description
When modifying the docstring of say some method via a decorator or explicitly mingling with __doc__
I'd expect pdoc to render the result.
Steps to reproduce the behavior:
Reproducer:
import pathlib
# import deprecation
#
#
# @deprecation.deprecated(deprecated_in="0.1.0", removed_in="1.0.0", details="This is not rendered.")
# def demo_deprecation():
# """This is always rendered."""
def demonstrate_doc_string_additions_do_not_get_rendered():
"""This docstring is always rendered as expected."""
demonstrate_doc_string_additions_do_not_get_rendered.__doc__ += "\n\nThis does not get rendered!"
def docstring_addition_decorator(function):
function.__doc__ = "" if function.__doc__ is None else function.__doc__
function.__doc__ += "\n\nDocstring added via decorator, also not rendered."
return function
@docstring_addition_decorator
def demo_two():
"""This is rendered as usual."""
@docstring_addition_decorator
def demo_decorator_only_works_if_no_docstring_set():
pass # if no docstring is set, the docstring gets added via decorator
pathlib.Path("log").write_text(demo_two.__doc__)
We want to use decorators for deprecation management, e.g. deprecation.
System Information
pdoc: 13.0.0
Python: 3.8.10
Platform: Windows-10-10.0.19042-SP0