Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Incorrectly dedenting class documentation (non PEP-257-compliant) #54

Closed
jaredkhan opened this issue Jun 27, 2020 · 2 comments
Closed
Labels
bug Something isn't working docstrings Docstrings parsing

Comments

@jaredkhan
Copy link
Contributor

jaredkhan commented Jun 27, 2020

Leading whitespace on class comments is not stripped correctly when the first line of text is on the same line as the triple-quotes.

A class like the following:

class A:
     """This is a class.
     
     More words here.
     """
     pass

ends up having whitespace stripped to look like this:

This is a class.

    More words here.

whereas this is expected:

This is a class.

More words here.

The intended behaviour is specified in PEP-257: Docstring Conventions > Handling Docstring Indentation and implemented in inspect.cleandoc (which is called by inspect.getdoc)

This is only a problem for classes, since elsewhere pytkdocs does use inspect.getdoc

@pawamoy
Copy link
Member

pawamoy commented Jun 27, 2020

Hi, thanks for the report 🙂

Indeed, I chose to use the __doc__ attribute directly to avoid inspect populating the docstring from parent classes. But I guess I could use inspect.cleandoc instead of textwrap.dedent!

@pawamoy pawamoy added bug Something isn't working docstrings Docstrings parsing labels Jun 27, 2020
@jaredkhan
Copy link
Contributor Author

Cool. Noticed this bug because it causes the later lines to be interpreted as code blocks. I'll open a PR :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working docstrings Docstrings parsing
Projects
None yet
Development

No branches or pull requests

2 participants