Skip to content

Commit 84f4fcf

Browse files
authored
Make custom_templates relative to config file
Fixes mkdocstrings#477.
1 parent f4a94f7 commit 84f4fcf

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎src/mkdocstrings/plugin.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from urllib import request
2424

2525
from mkdocs.config.config_options import Type as MkType
26+
from mkdocs.config.config_options import Dir
2627
from mkdocs.plugins import BasePlugin
2728
from mkdocs.utils import write_file
2829
from mkdocs_autorefs.plugin import AutorefsPlugin
@@ -78,7 +79,7 @@ class MkdocstringsPlugin(BasePlugin):
7879
config_scheme: tuple[tuple[str, MkType]] = ( # type: ignore[assignment]
7980
("handlers", MkType(dict, default={})),
8081
("default_handler", MkType(str, default="python")),
81-
("custom_templates", MkType(str, default=None)),
82+
("custom_templates", Dir(exists=True, required=False, default=None)),
8283
("enable_inventory", MkType(bool, default=None)),
8384
("enabled", MkType(bool, default=True)),
8485
)
@@ -90,7 +91,8 @@ class MkdocstringsPlugin(BasePlugin):
9091
- **`handlers`**: Global configuration of handlers. You can set global configuration per handler, applied everywhere,
9192
but overridable in each "autodoc" instruction. Example:
9293
- **`default_handler`**: The default handler to use. The value is the name of the handler module. Default is "python".
93-
- **`custom_templates`**: Custom templates to use when rendering API objects.
94+
- **`custom_templates`**: Location of custom templates to use when rendering API objects. Value should be the path of
95+
a directory relative to the mkdocs configuration file.
9496
- **`enable_inventory`**: Whether to enable object inventory creation.
9597
- **`enabled`**: Whether to enable the plugin. Default is true. If false, *mkdocstrings* will not collect or render anything.
9698

0 commit comments

Comments
 (0)