From debc2192d5ceb48f2d0db402dfa1fa85ad8c66c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 21 Apr 2022 12:45:53 +0200 Subject: [PATCH] feat: Pass config file path to handlers This is to allow handlers to build potential paths (like Python search paths) relative to the MkDocs configuration file path instead of the current working directory. Without it, the build becomes dependent on the CWD, breaking the --config-file option. Issue #311: https://github.com/mkdocstrings/mkdocstrings/issues/311 --- src/mkdocstrings/handlers/base.py | 5 +++-- src/mkdocstrings/plugin.py | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mkdocstrings/handlers/base.py b/src/mkdocstrings/handlers/base.py index 24eaa4d2..a8de29ac 100644 --- a/src/mkdocstrings/handlers/base.py +++ b/src/mkdocstrings/handlers/base.py @@ -571,8 +571,9 @@ def get_handler(self, name: str, handler_config: Optional[dict] = None) -> BaseH ) ) self._handlers[name] = module.get_handler( - self._config["theme_name"], - self._config["mkdocstrings"]["custom_templates"], + theme=self._config["theme_name"], + custom_templates=self._config["mkdocstrings"]["custom_templates"], + config_file_path=self._config["config_file_path"], **handler_config, ) return self._handlers[name] diff --git a/src/mkdocstrings/plugin.py b/src/mkdocstrings/plugin.py index 4f2fdda6..fd47291a 100644 --- a/src/mkdocstrings/plugin.py +++ b/src/mkdocstrings/plugin.py @@ -166,6 +166,7 @@ def on_config(self, config: Config, **kwargs: Any) -> Config: # noqa: W0613 (un extension_config = { "site_name": config["site_name"], + "config_file_path": config["config_file_path"], "theme_name": theme_name, "mdx": config["markdown_extensions"], "mdx_configs": config["mdx_configs"],