Skip to content

Commit

Permalink
refactor: Deprecate crossref and multi_crossref filters
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Aug 16, 2023
1 parent 8410593 commit 4fe3d20
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/mkdocstrings_handlers/python/rendering.py
Expand Up @@ -5,6 +5,7 @@
import enum
import re
import sys
import warnings
from functools import lru_cache
from typing import TYPE_CHECKING, Any, Callable, Match, Pattern, Sequence

Expand Down Expand Up @@ -131,6 +132,15 @@ def do_order_members(
return sorted(members, key=order_map[order])


@lru_cache
def _warn_crossref() -> None:
warnings.warn(
"The `crossref` filter is deprecated and will be removed in a future version",
DeprecationWarning,
stacklevel=1,
)


def do_crossref(path: str, *, brief: bool = True) -> Markup:
"""Filter to create cross-references.
Expand All @@ -141,12 +151,22 @@ def do_crossref(path: str, *, brief: bool = True) -> Markup:
Returns:
Markup text.
"""
_warn_crossref()
full_path = path
if brief:
path = full_path.split(".")[-1]
return Markup("<span data-autorefs-optional-hover={full_path}>{path}</span>").format(full_path=full_path, path=path)


@lru_cache
def _warn_multi_crossref() -> None:
warnings.warn(
"The `multi_crossref` filter is deprecated and will be removed in a future version",
DeprecationWarning,
stacklevel=1,
)


def do_multi_crossref(text: str, *, code: bool = True) -> Markup:
"""Filter to create cross-references.
Expand All @@ -157,6 +177,7 @@ def do_multi_crossref(text: str, *, code: bool = True) -> Markup:
Returns:
Markup text.
"""
_warn_multi_crossref()
group_number = 0
variables = {}

Expand Down

0 comments on commit 4fe3d20

Please sign in to comment.