Skip to content

Commit 15bb65a

Browse files
committed
Fixed empty generated markdown files due to issue ml-tooling#57
Inherently also fixed issue ml-tooling#69 Some whitespace removal.
1 parent 5a645ab commit 15bb65a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/lazydocs/generation.py

+16-6
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ def to_md_file(
220220
return
221221

222222
md_file = filename
223-
223+
224224
if is_mdx:
225225
if not filename.endswith(".mdx"):
226226
md_file = filename + ".mdx"
@@ -614,7 +614,7 @@ def func2md(self, func: Callable, clsname: str = "", depth: int = 3, is_mdx: boo
614614
if path:
615615
if is_mdx:
616616
markdown = _MDX_SOURCE_BADGE_TEMPLATE.format(path=path) + markdown
617-
else:
617+
else:
618618
markdown = _SOURCE_BADGE_TEMPLATE.format(path=path) + markdown
619619

620620
return markdown
@@ -998,8 +998,13 @@ def generate_docs(
998998
continue
999999

10001000
try:
1001-
mod_spec = loader.find_spec(module_name)
1002-
mod = importlib.util.module_from_spec(mod_spec)
1001+
try:
1002+
mod_spec = loader.find_spec(module_name)
1003+
mod = importlib.util.module_from_spec(mod_spec)
1004+
mod_spec.loader.exec_module(mod)
1005+
except AttributeError:
1006+
# For older python version compatibility
1007+
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
10031008
module_md = generator.module2md(mod, is_mdx=is_mdx)
10041009
if not module_md:
10051010
# Module md is empty -> ignore module and all submodules
@@ -1077,8 +1082,13 @@ def generate_docs(
10771082
continue
10781083

10791084
try:
1080-
mod_spec = loader.find_spec(module_name)
1081-
mod = importlib.util.module_from_spec(mod_spec)
1085+
try:
1086+
mod_spec = loader.find_spec(module_name)
1087+
mod = importlib.util.module_from_spec(mod_spec)
1088+
mod_spec.loader.exec_module(mod)
1089+
except AttributeError:
1090+
# For older python version compatibility
1091+
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
10821092
module_md = generator.module2md(mod, is_mdx=is_mdx)
10831093

10841094
if not module_md:

0 commit comments

Comments
 (0)