Skip to content

Commit ad09a2d

Browse files
committed
chore: Comment code in handler init method
1 parent 929cfb5 commit ad09a2d

File tree

1 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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy