8000 chore: Comment code in handler init method · melissawm/mkdocstrings-python@ad09a2d · GitHub
[go: up one dir, main page]

Skip to content
file changed
+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/mkdocstrings_handlers/python/handler.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,28 @@ def __init__(
223223
self._config_file_path = config_file_path
224224
self._load_external_modules = load_external_modules
225225
paths = paths or []
226+
227+
# Expand paths with glob patterns.
226228
glob_base_dir = os.path.dirname(os.path.abspath(config_file_path)) if config_file_path else "."
227229
with chdir(glob_base_dir):
228230
resolved_globs = [glob.glob(path) for path in paths]
229231
paths = [path for glob_list in resolved_globs for path in glob_list]
232+
233+
# By default, add the directory of the config file to the search paths.
230234
if not paths and config_file_path:
231235
paths.append(os.path.dirname(config_file_path))
232-
search_paths = [path for path in sys.path if path] # eliminate empty path
236+
237+
# Initialize search paths from `sys.path`, eliminating empty paths.
238+
search_paths = [path for path in sys.path if path]
239+
233240
for path in reversed(paths):
241+
# If it's not absolute, make path relative to the config file path, then make it absolute.
234242
if not os.path.isabs(path) and config_file_path:
235243
path = os.path.abspath(os.path.join(os.path.dirname(config_file_path), path)) # noqa: PLW2901
244+
# Don't add duplicates.
236245
if path not in search_paths:
237246
search_paths.insert(0, path)
247+
238248
self._paths = search_paths
239249
self._modules_collection: ModulesCollection = ModulesCollection()
240250
self._lines_collection: LinesCollection = LinesCollection()

0 commit comments

Comments
 (0)
0