Skip to content

Module-level docstring section name disrupts parsing of class code #143

Open
@cheshyre

Description

@cheshyre

Expected Behavior

When dealing with docstrings at the module level and the class level, pdoc3 should include the valid source code for the class in the rendered HTML, regardless of what is in module-level docstrings.

Actual Behavior

Including a section name in the module-level docstring that matches the name of a class to be documented causes pdoc3 to fail to parse the source and as a result fail to include it in the rendered HTML.

Steps to Reproduce

  1. Create file min_working_example.py:
"""Module docstring.

Some additional text.

class ABC
---------

This header creates the problem.

class `DEF`
-----------

This header does not create a problem.

"""
from __future__ import absolute_import
from __future__ import unicode_literals


__all__ = ["ABC", "DEF"]


class ABC:
    """ABC class docstring."""

    def __init__(self):
        """Construct object."""
        self.name = "ABC"

class DEF:
    """DEF class docstring."""

    def __init__(self):
        """Construct object."""
        self.name = "DEF"
  1. Run pdoc3 --html min_working_example which yields the following error:
~/.local/lib/python3.6/site-packages/pdoc/__init__.py:227: UserWarning: Couldn't get/parse source of '<Class 'min_working_example.ABC'>'
  warn("Couldn't get/parse source of '{!r}'".format(doc_obj))

Additional info

Metadata

Metadata

Assignees

No one assigned

    Labels

    upstreamIssue affects a dependency of ours

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions