From 5668abba15b13b86fe67f70f6b4004b7b1feeb4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Thu, 16 May 2024 00:51:39 +0200 Subject: [PATCH] fix: Actually make use of custom .html.jinja templates --- src/mkdocstrings_handlers/python/rendering.py | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/mkdocstrings_handlers/python/rendering.py b/src/mkdocstrings_handlers/python/rendering.py index 479597c2..face49fe 100644 --- a/src/mkdocstrings_handlers/python/rendering.py +++ b/src/mkdocstrings_handlers/python/rendering.py @@ -474,25 +474,25 @@ def do_get_template(env: Environment, obj: str | Object) -> str | Template: template = env.get_template(f"{name}.html") except TemplateNotFound: return f"{name}.html.jinja" - else: - # TODO: Remove once support for Python 3.8 is dropped. - if sys.version_info < (3, 9): - try: - Path(template.filename).relative_to(Path(__file__).parent) # type: ignore[arg-type] - except ValueError: - our_template = False - else: - our_template = True + # TODO: Remove once support for Python 3.8 is dropped. + if sys.version_info < (3, 9): + try: + Path(template.filename).relative_to(Path(__file__).parent) # type: ignore[arg-type] + except ValueError: + our_template = False else: - our_template = Path(template.filename).is_relative_to(Path(__file__).parent) # type: ignore[arg-type] - if not our_template: - # TODO: Switch to a warning log after some time. - logger.info( - f"DeprecationWarning: Overriding '{name}.html' is deprecated, override '{name}.html.jinja' instead. " - "After some time, this message will be logged as a warning, causing strict builds to fail.", - once=True, - ) - return f"{name}.html" + our_template = True + else: + our_template = Path(template.filename).is_relative_to(Path(__file__).parent) # type: ignore[arg-type] + if our_template: + return f"{name}.html.jinja" + # TODO: Switch to a warning log after some time. + logger.info( + f"DeprecationWarning: Overriding '{name}.html' is deprecated, override '{name}.html.jinja' instead. " + "After some time, this message will be logged as a warning, causing strict builds to fail.", + once=True, + ) + return f"{name}.html" @pass_context