From 29edd02e7a4d83f6b7e8555d4d5b03a79882eb07 Mon Sep 17 00:00:00 2001 From: Andrew Guenther Date: Fri, 23 Sep 2022 11:32:45 -0700 Subject: [PATCH] feat: Add support for globs in paths configuration This change allows for values in the paths configuration option to be globs by resolving them before passing them off to Griffe. Issue #33: https://github.com/mkdocstrings/python/issues/33 PR #34: https://github.com/mkdocstrings/python/pull/34 --- src/mkdocstrings_handlers/python/handler.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py index 73247f6..bb73115 100644 --- a/src/mkdocstrings_handlers/python/handler.py +++ b/src/mkdocstrings_handlers/python/handler.py @@ -2,6 +2,7 @@ from __future__ import annotations +import glob import os import posixpath import re @@ -128,6 +129,8 @@ def __init__( super().__init__(*args, **kwargs) self._config_file_path = config_file_path paths = paths or [] + resolved_globs = [glob.glob(path) for path in paths] + paths = [path for glob_list in resolved_globs for path in glob_list] 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