From 749e48c5f8d072729d9afad23b917ebb8a5245cf Mon Sep 17 00:00:00 2001 From: Andrew Guenther Date: Wed, 10 Aug 2022 10:48:53 -0700 Subject: [PATCH 1/2] 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. fixes #33 --- mkdocs.yml | 2 ++ src/mkdocstrings_handlers/python/handler.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index 6b851eed..4a9a18a1 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -83,6 +83,8 @@ plugins: - https://mkdocstrings.github.io/objects.inv - https://mkdocstrings.github.io/griffe/objects.inv options: + paths: + - src/* docstring_style: google docstring_options: ignore_init_summary: yes diff --git a/src/mkdocstrings_handlers/python/handler.py b/src/mkdocstrings_handlers/python/handler.py index 301f02fc..41f32463 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 @@ -127,6 +128,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 From db7e8ddaad3cd0a49b08fc3750a11261c688b0ca Mon Sep 17 00:00:00 2001 From: Andrew Guenther Date: Wed, 17 Aug 2022 15:39:18 -0700 Subject: [PATCH 2/2] Remove paths config from mkdocs.yml --- mkdocs.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/mkdocs.yml b/mkdocs.yml index 4a9a18a1..6b851eed 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -83,8 +83,6 @@ plugins: - https://mkdocstrings.github.io/objects.inv - https://mkdocstrings.github.io/griffe/objects.inv options: - paths: - - src/* docstring_style: google docstring_options: ignore_init_summary: yes