Skip to content

Commit

Permalink
Fixed empty generated markdown files due to issue ml-tooling#57
Browse files Browse the repository at this point in the history
Inherently also fixed issue ml-tooling#69
Some whitespace removal.
  • Loading branch information
ltan10 committed Feb 7, 2025
1 parent 5a645ab commit 15bb65a
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/lazydocs/generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def to_md_file(
return

md_file = filename

if is_mdx:
if not filename.endswith(".mdx"):
md_file = filename + ".mdx"
Expand Down Expand Up @@ -614,7 +614,7 @@ def func2md(self, func: Callable, clsname: str = "", depth: int = 3, is_mdx: boo
if path:
if is_mdx:
markdown = _MDX_SOURCE_BADGE_TEMPLATE.format(path=path) + markdown
else:
else:
markdown = _SOURCE_BADGE_TEMPLATE.format(path=path) + markdown

return markdown
Expand Down Expand Up @@ -998,8 +998,13 @@ def generate_docs(
continue

try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
mod_spec.loader.exec_module(mod)
except AttributeError:
# For older python version compatibility
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
module_md = generator.module2md(mod, is_mdx=is_mdx)
if not module_md:
# Module md is empty -> ignore module and all submodules
Expand Down Expand Up @@ -1077,8 +1082,13 @@ def generate_docs(
continue

try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
try:
mod_spec = loader.find_spec(module_name)
mod = importlib.util.module_from_spec(mod_spec)
mod_spec.loader.exec_module(mod)
except AttributeError:
# For older python version compatibility
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
module_md = generator.module2md(mod, is_mdx=is_mdx)

if not module_md:
Expand Down

0 comments on commit 15bb65a

Please # to comment.