Skip to content

Commit 57fc671

Browse files
authored
Merge pull request #28 from facelessuser/chore/deprecate
Deprecate the library
2 parents 16ae7a3 + 1a1139d commit 57fc671

File tree

4 files changed

+61
-1
lines changed

4 files changed

+61
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
![License][license-image-mit]
77
# MkDocs Material Extensions
88

9+
> NOTE: This project is now deprecated as MkDocs for Material now implements this logic directly.
10+
> Users should migrate to using `mkdocs-material`'s `material.extensions.emoji.twemoji` and
11+
> `material.extensions.emoji.to_svg` in place of the respective `materialx.emoji.twemoji` and `materialx.emoji.to_svg`
12+
> functions provided by this library.
13+
914
Markdown extension resources for [MkDocs for Material][mkdocs-material]
1015

1116
## Install

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.3
4+
5+
- **NEW**: The final release. `mkdocs-material` (version 9.4) now has this library's logic built-in making this library
6+
obsolete. Users should migrate to using `mkdocs-material`'s `material.extensions.emoji.twemoji` and
7+
`material.extensions.emoji.to_svg` in place of the respective `materialx.emoji.twemoji` and `materialx.emoji.to_svg`
8+
functions.
9+
310
## 1.2
411

512
- **NEW**: Add official support for Python 3.11 and 3.12.

materialx/__meta__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,5 +188,5 @@ def parse_version(ver):
188188
return Version(major, minor, micro, release, pre, post, dev)
189189

190190

191-
__version_info__ = Version(1, 2, 0, "final")
191+
__version_info__ = Version(1, 3, 0, "final")
192192
__version__ = __version_info__._get_canonical()

materialx/emoji.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@
1313
import pymdownx
1414
from pymdownx.emoji import TWEMOJI_SVG_CDN, add_attriubtes
1515
import xml.etree.ElementTree as etree # noqa: N813
16+
import warnings
17+
from functools import wraps
18+
import logging
19+
20+
log = logging.getLogger('mkdocs')
21+
22+
DEPRECATED = """\
23+
Material emoji logic has been officially moved into mkdocs-material
24+
version 9.4. Please use Material's '{}'
25+
as mkdocs_material_extensions is deprecated and will no longer be
26+
supported moving forward. This is the last release.
27+
"""
28+
1629

1730
OPTION_SUPPORT = pymdownx.__version_info__ >= (7, 1, 0)
1831
RESOURCES = os.path.dirname(inspect.getfile(material))
@@ -22,6 +35,40 @@
2235
RES_PATH = os.path.join(RESOURCES, '.icons')
2336

2437

38+
@functools.lru_cache(maxsize=None)
39+
def log_msg(message):
40+
"""Log message."""
41+
42+
log.warning(message)
43+
44+
45+
def deprecated(message, stacklevel=2, name=None): # pragma: no cover
46+
"""
47+
Raise a `DeprecationWarning` when wrapped function/method is called.
48+
49+
Usage:
50+
51+
@deprecated("This method will be removed in version X; use Y instead.")
52+
def some_method()"
53+
pass
54+
"""
55+
56+
def _wrapper(func):
57+
@wraps(func)
58+
def _deprecated_func(*args, **kwargs):
59+
warnings.warn(
60+
f"'{func.__name__ if name is None else name}' is deprecated.\n{message}",
61+
category=DeprecationWarning,
62+
stacklevel=stacklevel
63+
)
64+
65+
log_msg(message)
66+
return func(*args, **kwargs)
67+
return _deprecated_func
68+
return _wrapper
69+
70+
71+
@deprecated(DEPRECATED.format('material.extensions.emoji.twemoji'), name='materialx.emoji.twemoji')
2572
def _patch_index(options):
2673
"""Patch the given index."""
2774

@@ -65,6 +112,7 @@ def twemoji():
65112
return _patch_index({})
66113

67114

115+
@deprecated(DEPRECATED.format('material.extensions.emoji.to_svg'), 1, name='materialx.emoji.to_svg')
68116
def to_svg(index, shortname, alias, uc, alt, title, category, options, md):
69117
"""Return SVG element."""
70118

0 commit comments

Comments
 (0)