File tree 3 files changed +15
-3
lines changed
3 files changed +15
-3
lines changed Original file line number Diff line number Diff line change 6
6
7
7
* migrated to `mkdocs-material` as part of development
8
8
* fixed bug in RDF for function parameters
9
-
9
+ * using `imporlib` approach to find local source module
10
+ * fixed bug when apidocs is not configured
10
11
11
12
## 0.2.0
12
13
Original file line number Diff line number Diff line change 23
23
You're welcome.
24
24
"""
25
25
26
+ import importlib
26
27
import inspect
27
28
import os
28
29
import re
@@ -74,7 +75,13 @@ def __init__ (
74
75
self .git_url = git_url
75
76
self .class_list = class_list
76
77
77
- self .package_obj = sys .modules [self .package_name ]
78
+ # hunt for the package
79
+ spec = importlib .util .spec_from_file_location (self .package_name , self .package_name + "/__init__.py" )
80
+
81
+ #self.package_obj = sys.modules[self.package_name]
82
+ self .package_obj = importlib .util .module_from_spec (spec )
83
+ spec .loader .exec_module (self .package_obj ) # type: ignore
84
+ sys .modules [spec .name ] = self .package_obj
78
85
79
86
# prepare a file path prefix (to remove later, per file)
80
87
pkg_path = os .path .dirname (inspect .getfile (self .package_obj ))
Original file line number Diff line number Diff line change @@ -70,6 +70,7 @@ def __init__ (self):
70
70
self .enabled = True
71
71
self .local_config : dict = defaultdict ()
72
72
73
+ self .apidocs_used = False
73
74
self .apidocs_file = None
74
75
75
76
self .glossary_kg = None
@@ -146,6 +147,9 @@ def on_config ( # pylint: disable=W0613
146
147
147
148
reuse_graph_path = None
148
149
150
+ if self ._valid_component_config (yaml_path , "apidocs" ):
151
+ self .apidocs_used = True
152
+
149
153
if self ._valid_component_config (yaml_path , "glossary" ):
150
154
# load the KG for the glossary
151
155
try :
@@ -196,7 +200,7 @@ def on_files ( # pylint: disable=W0613
196
200
returns:
197
201
the possibly modified global files collection
198
202
"""
199
- if self .local_config ["apidocs" ]["page" ]:
203
+ if self .apidocs_used and self . local_config ["apidocs" ]["page" ]:
200
204
self .apidocs_file = mkdocs .structure .files .File (
201
205
path = self .local_config ["apidocs" ]["page" ],
202
206
src_dir = config ["docs_dir" ],
You can’t perform that action at this time.
0 commit comments