Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

"Dynamically" Modified Docstrings Are Not Rendered #536

Closed
lovetheguitar opened this issue Apr 12, 2023 · 0 comments · Fixed by #537
Closed

"Dynamically" Modified Docstrings Are Not Rendered #536

lovetheguitar opened this issue Apr 12, 2023 · 0 comments · Fixed by #537
Labels

Comments

@lovetheguitar
Copy link

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.

Rendered Output:
image

System Information

pdoc: 13.0.0
Python: 3.8.10
Platform: Windows-10-10.0.19042-SP0
@lovetheguitar lovetheguitar changed the title "Dynamically" Added/Modified Docstrings Are Not Rendered "Dynamically" Modified Docstrings Are Not Rendered Apr 12, 2023
mhils added a commit that referenced this issue Apr 24, 2023
….func_docstrings`

This distinction ensure that we can better take decorators into account, refs #536
mhils added a commit that referenced this issue Apr 24, 2023
….func_docstrings`

This distinction ensure that we can better take decorators into account, refs #536
@mhils mhils linked a pull request Apr 24, 2023 that will close this issue
mhils added a commit that referenced this issue Apr 24, 2023
….func_docstrings`

This distinction ensure that we can better take decorators into account, refs #536
@mhils mhils closed this as completed in ec22514 Apr 24, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant