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

Arbitrary documentation is generated for undocumented enum, with python 3.12 #701

Closed
mfrigerio17 opened this issue Jun 20, 2024 · 1 comment
Labels

Comments

@mfrigerio17
Copy link

Hi,
With an undocumented enum like this

from enum import Enum

class MyEnum(Enum):
    one = 1,
    two = 2

pdoc 14.5.0 with python 3.12 generates html with some "default" documentation of a Color enum.

The same pdoc version with python 3.10 behaves as expected, i.e. the html docs do not say anything (besides "An enumeration").

Not a sever bug, a bit funny I would say :)

@mhils
Copy link
Member

mhils commented Jun 20, 2024

Thanks! Enums probably just need to be added here:

pdoc/pdoc/doc.py

Lines 587 to 598 in dea7fa0

if doc == dict.__doc__:
# Don't display default docstring for dict subclasses (primarily TypedDict).
return ""
is_dataclass_with_default_docstring = (
dataclasses.is_dataclass(self.obj)
# from https://github.com/python/cpython/blob/3.10/Lib/dataclasses.py
and doc
== self.obj.__name__
+ str(inspect.signature(self.obj)).replace(" -> None", "")
)
if is_dataclass_with_default_docstring:
return ""

mhils added a commit to mhils/pdoc that referenced this issue Jul 10, 2024
mhils added a commit to mhils/pdoc that referenced this issue Jul 10, 2024
@mhils mhils closed this as completed in a3d4946 Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants