Skip to content

Commit 87a3d59

Browse files
committed
Fixes functions not rendered during markdown generation and no "find_module" AttributeError
Caused by modules not correctly loaded into namespace from commit due to Issue ml-tooling#57. Modules now correctly loaded into namespace. Fixes AttributeError("'FileFinder' object has no attribute 'find_module'") (ml-tooling#69) Prioritized "find_spec" and falls back to "find_module" from loader if find_spec not available. Some whitespace removal.
1 parent 0c9eb45 commit 87a3d59

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/lazydocs/generation.py

+14-4
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,13 @@ def generate_docs(
10111011
continue
10121012

10131013
try:
1014-
mod_spec = loader.find_spec(module_name)
1015-
mod = importlib.util.module_from_spec(mod_spec)
1014+
try:
1015+
mod_spec = importlib.util.spec_from_loader(module_name, loader)
1016+
mod = importlib.util.module_from_spec(mod_spec)
1017+
mod_spec.loader.exec_module(mod)
1018+
except AttributeError:
1019+
# For older python version compatibility
1020+
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
10161021
module_md = generator.module2md(mod, is_mdx=is_mdx)
10171022
if not module_md:
10181023
# Module md is empty -> ignore module and all submodules
@@ -1090,8 +1095,13 @@ def generate_docs(
10901095
continue
10911096

10921097
try:
1093-
mod_spec = loader.find_spec(module_name)
1094-
mod = importlib.util.module_from_spec(mod_spec)
1098+
try:
1099+
mod_spec = importlib.util.spec_from_loader(module_name, loader)
1100+
mod = importlib.util.module_from_spec(mod_spec)
1101+
mod_spec.loader.exec_module(mod)
1102+
except AttributeError:
1103+
# For older python version compatibility
1104+
mod = loader.find_module(module_name).load_module(module_name) # type: ignore
10951105
module_md = generator.module2md(mod, is_mdx=is_mdx)
10961106

10971107
if not module_md:

0 commit comments

Comments
 (0)