Skip to content

Commit 26e3d66

Browse files
committed
refactor: Log a warning when base templates are overridden
Issue-151: mkdocstrings#151
1 parent 2bc156b commit 26e3d66

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/mkdocstrings_handlers/python/handler.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import sys
1010
from collections import ChainMap
1111
from contextlib import suppress
12+
from pathlib import Path
1213
from typing import TYPE_CHECKING, Any, BinaryIO, ClassVar, Iterator, Mapping, Sequence
1314

1415
from griffe.collections import LinesCollection, ModulesCollection
@@ -208,6 +209,17 @@ def __init__(
208209
**kwargs: Same thing, but with keyword arguments.
209210
"""
210211
super().__init__(*args, **kwargs)
212+
213+
# Warn if user overrides base templates.
214+
if custom_templates := kwargs.get("custom_templates", ()):
215+
config_dir = Path(config_file_path or "./mkdocs.yml").parent
216+
for theme_dir in config_dir.joinpath(custom_templates, "python").iterdir():
217+
if theme_dir.joinpath("_base").is_dir():
218+
logger.warning(
219+
f"Overriding base template '{theme_dir.name}/_base/<template>.html.jinja' is not supported, "
220+
f"override '{theme_dir.name}/<template>.html.jinja' instead",
221+
)
222+
211223
self._config_file_path = config_file_path
212224
self._load_external_modules = load_external_modules
213225
paths = paths or []

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy