Skip to content

Commit abad5fc

Browse files
committed
Support remove prefix feature for class properties
1 parent ad5cb63 commit abad5fc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/lazydocs/generation.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -557,18 +557,25 @@ def class2md(self, cls: Any, depth: int = 2) -> str:
557557
if not name.startswith("_") and type(obj) == property:
558558
comments = self.doc2md(obj) or inspect.getcomments(obj)
559559
comments = "\n %s" % comments if comments else ""
560+
property_name = f"{clsname}.{name}"
561+
if self.remove_package_prefix:
562+
property_name = name
560563
variables.append(
561-
"\n%s <kbd>property</kbd> %s.%s%s\n"
562-
% (subsection, clsname, name, comments)
564+
"\n%s <kbd>property</kbd> %s%s\n"
565+
% (subsection, property_name, comments)
563566
)
564567

565568
handlers = []
566569
for name, obj in getmembers(cls, inspect.ismethoddescriptor):
567570
if not name.startswith("_") and hasattr(
568571
obj, "__module__"
569572
): # and obj.__module__ == modname:
573+
handler_name = f"{clsname}.{name}"
574+
if self.remove_package_prefix:
575+
handler_name = name
576+
570577
handlers.append(
571-
"\n%s <kbd>handler</kbd> %s.%s\n" % (subsection, clsname, name)
578+
"\n%s <kbd>handler</kbd> %s\n" % (subsection, handler_name)
572579
)
573580

574581
methods = []

0 commit comments

Comments
 (0)