Skip to content
Snippets Groups Projects
Commit c97b0646 authored by Kai Knoblich's avatar Kai Knoblich
Browse files

textproc/py-mkdocstrings: Add support for Jinja2 3.1

* The newer releases of py-mkdocstrings need some additional
  dependencies, which are not yet available as ports.

  Thus backport a patch of the 0.18.0 release to add compatibility for
  Jinja2 3.1.  This fixes the runtime regarding "contextfunction" that
  was replaced with "pass_context" in Jinja2 3.1 after 23cc4385.

* Bump PORTREVISION due package change.
parent c33502d2
No related branches found
No related tags found
No related merge requests found
PORTNAME= mkdocstrings
DISTVERSION= 0.17.0
PORTREVISION= 1
CATEGORIES= textproc python
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
......
From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= <pawamoy@pm.me>
Date: Wed, 2 Feb 2022 12:27:27 +0100
Subject: [PATCH] refactor: Support Jinja2 3.1
Issue #360: https://github.com/mkdocstrings/mkdocstrings/issues/360
PR #361: https://github.com/mkdocstrings/mkdocstrings/issues/361
--- src/mkdocstrings/loggers.py.orig 2021-12-27 17:59:33 UTC
+++ src/mkdocstrings/loggers.py
@@ -4,10 +4,14 @@ from typing import Any, Callable, Optional, Tuple
from pathlib import Path
from typing import Any, Callable, Optional, Tuple
-from jinja2 import contextfunction
from jinja2.runtime import Context
from mkdocs.utils import warning_filter
+try:
+ from jinja2 import pass_context
+except ImportError: # TODO: remove once Jinja2 < 3.1 is dropped
+ from jinja2 import contextfunction as pass_context # noqa: WPS440
+
TEMPLATES_DIR = Path(__file__).parent / "templates"
@@ -71,7 +75,7 @@ def get_template_logger_function(logger_func: Callable
A function.
"""
- @contextfunction
+ @pass_context
def wrapper(context: Context, msg: Optional[str] = None) -> str:
"""Log a message.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment