Skip to content

Commit

Permalink
feat: Add option to search for stubs packages
Browse files Browse the repository at this point in the history
This allows using the feature in griffe that searches for stubs packages

Related: mkdocstrings/griffe#221
  • Loading branch information
romain-intel committed Feb 1, 2024
1 parent 548bdad commit a053ca5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/mkdocstrings_handlers/python/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class PythonHandler(BaseHandler):
fallback_config: ClassVar[dict] = {"fallback": True}
"""The configuration used to collect item during autorefs fallback."""
default_config: ClassVar[dict] = {
"find_stubs_package": False,
"docstring_style": "google",
"docstring_options": {},
"show_symbol_type_heading": False,
Expand Down Expand Up @@ -110,6 +111,7 @@ class PythonHandler(BaseHandler):
"""Default handler configuration.
Attributes: General options:
find_stubs_package (bool): Whether to load stubs package (package-stubs) when extracting docstrings
allow_inspection (bool): Whether to allow inspecting modules when visiting them is not possible. Default: `True`.
show_bases (bool): Show the base classes of a class. Default: `True`.
show_source (bool): Show the source code of this object. Default: `True`.
Expand Down Expand Up @@ -279,7 +281,7 @@ def collect(self, identifier: str, config: Mapping[str, Any]) -> CollectorItem:
try:
for pre_loaded_module in final_config.get("preload_modules") or []:
if pre_loaded_module not in self._modules_collection:
loader.load(pre_loaded_module)
loader.load(pre_loaded_module, find_stubs_package=final_config["find_stubs_package"])
loader.load(module_name)
except ImportError as error:
raise CollectionError(str(error)) from error
Expand Down

0 comments on commit a053ca5

Please sign in to comment.