@@ -220,7 +220,7 @@ def to_md_file(
220
220
return
221
221
222
222
md_file = filename
223
-
223
+
224
224
if is_mdx :
225
225
if not filename .endswith (".mdx" ):
226
226
md_file = filename + ".mdx"
@@ -614,7 +614,7 @@ def func2md(self, func: Callable, clsname: str = "", depth: int = 3, is_mdx: boo
614
614
if path :
615
615
if is_mdx :
616
616
markdown = _MDX_SOURCE_BADGE_TEMPLATE .format (path = path ) + markdown
617
- else :
617
+ else :
618
618
markdown = _SOURCE_BADGE_TEMPLATE .format (path = path ) + markdown
619
619
620
620
return markdown
@@ -998,8 +998,13 @@ def generate_docs(
998
998
continue
999
999
1000
1000
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
1003
1008
module_md = generator .module2md (mod , is_mdx = is_mdx )
1004
1009
if not module_md :
1005
1010
# Module md is empty -> ignore module and all submodules
@@ -1077,8 +1082,13 @@ def generate_docs(
1077
1082
continue
1078
1083
1079
1084
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
1082
1092
module_md = generator .module2md (mod , is_mdx = is_mdx )
1083
1093
1084
1094
if not module_md :
0 commit comments