Skip to content

Commit b20fb55

Browse files
committed
Fix problem with missing __module__ in functions
1 parent 845601c commit b20fb55

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/lazydocs/generation.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ def func2md(self, func: Callable, clsname: str = "", depth: int = 3) -> str:
445445

446446
section = "#" * depth
447447
funcname = func.__name__
448-
modname = func.__module__
448+
modname = None
449+
if hasattr(func, "__module__"):
450+
modname = func.__module__
449451

450452
escfuncname = (
451453
"%s" % funcname if funcname.startswith("_") else funcname
@@ -713,7 +715,11 @@ def overview2md(self) -> str:
713715
filter(lambda d: d["type"] == "module", self.generated_objects)
714716
):
715717
full_name = obj["full_name"]
716-
link = "./" + obj["module"] + ".md#" + obj["anchor_tag"]
718+
if "module" in obj:
719+
link = "./" + obj["module"] + ".md#" + obj["anchor_tag"]
720+
else:
721+
link = "#unknown"
722+
717723
description = obj["description"]
718724
entries_md += f"\n- [`{full_name}`]({link})"
719725
if description:

0 commit comments

Comments
 (0)