Skip to content

Commit 9ebc2f4

Browse files
committed
Fixed visible attribute header for dataclass decorated class with no attributes
Changed terminology of dataclass attribute header to fields and implement inclusion of class prefix.
1 parent 4971487 commit 9ebc2f4

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

src/lazydocs/generation.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -836,9 +836,6 @@ def class2md(self, cls: Any, depth: int = 2, is_mdx: bool = False) -> str:
836836
)
837837
elif is_dataclass(cls):
838838
kind = "dataclass"
839-
variables.append(
840-
"%s <kbd>attributes</kbd>\n" % (sectionheader)
841-
)
842839
elif issubclass(cls, Exception):
843840
kind = "exception"
844841
else:
@@ -887,10 +884,16 @@ def class2md(self, cls: Any, depth: int = 2, is_mdx: bool = False) -> str:
887884
variables.append(
888885
"- **%s** = %s\n" % (full_name, obj.value)
889886
)
890-
elif name == "__dataclass_fields__":
887+
elif name == "__dataclass_fields__" and obj:
888+
variables.append(
889+
"%s <kbd>fields</kbd>\n" % (sectionheader)
890+
)
891891
for name, field in sorted((obj).items()):
892+
full_name = f"{clsname}.{name}"
893+
if self.remove_package_prefix:
894+
full_name = name
892895
variables.append(
893-
"- ```%s``` (%s)\n" % (name,
896+
"- ```%s``` (%s)\n" % (full_name,
894897
field.type.__name__)
895898
)
896899

0 commit comments

Comments
 (0)