Skip to content

Commit

Permalink
chore: Comment code in handler init method
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Apr 28, 2024
1 parent 929cfb5 commit ad09a2d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/mkdocstrings_handlers/python/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,18 +223,28 @@ def __init__(
self._config_file_path = config_file_path
self._load_external_modules = load_external_modules
paths = paths or []

# Expand paths with glob patterns.
glob_base_dir = os.path.dirname(os.path.abspath(config_file_path)) if config_file_path else "."
with chdir(glob_base_dir):
resolved_globs = [glob.glob(path) for path in paths]
paths = [path for glob_list in resolved_globs for path in glob_list]

# By default, add the directory of the config file to the search paths.
if not paths and config_file_path:
paths.append(os.path.dirname(config_file_path))
search_paths = [path for path in sys.path if path] # eliminate empty path

# Initialize search paths from `sys.path`, eliminating empty paths.
search_paths = [path for path in sys.path if path]

for path in reversed(paths):
# If it's not absolute, make path relative to the config file path, then make it absolute.
if not os.path.isabs(path) and config_file_path:
path = os.path.abspath(os.path.join(os.path.dirname(config_file_path), path)) # noqa: PLW2901
# Don't add duplicates.
if path not in search_paths:
search_paths.insert(0, path)

self._paths = search_paths
self._modules_collection: ModulesCollection = ModulesCollection()
self._lines_collection: LinesCollection = LinesCollection()
Expand Down

0 comments on commit ad09a2d

Please sign in to comment.