Skip to content

Commit ebcbe60

Browse files
committed
Remove ParserExtensionInterface.add_cli_options
1 parent 443084b commit ebcbe60

File tree

4 files changed

+1
-55
lines changed

4 files changed

+1
-55
lines changed

docs/users/changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Note that there is currently no guarantee for a stable Markdown formatting style
77

88
- Removed
99
- `mdformat.codepoints.ASCII_WHITESPACE` (deprecated since 0.7.20)
10+
- `mdformat.plugins.ParserExtensionInterface.add_cli_options` (deprecated since 0.7.19)
1011
- Fixed
1112
- Read UTF-8 from standard input on all systems.
1213
Thank you, [Christopher Prohm](https://github.com/chmp), for the PR.

src/mdformat/_cli.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -283,20 +283,6 @@ def make_arg_parser(
283283
dest="codeformatters",
284284
help=argparse.SUPPRESS,
285285
)
286-
for plugin in parser_extensions.values():
287-
if hasattr(plugin, "add_cli_options"):
288-
import warnings
289-
290-
plugin_file, plugin_line = get_source_file_and_line(plugin)
291-
warnings.warn_explicit(
292-
"`mdformat.plugins.ParserExtensionInterface.add_cli_options`"
293-
" is deprecated."
294-
" Please use `add_cli_argument_group`.",
295-
DeprecationWarning,
296-
filename=plugin_file,
297-
lineno=plugin_line,
298-
)
299-
plugin.add_cli_options(parser)
300286
for plugin_id, plugin in parser_extensions.items():
301287
if hasattr(plugin, "add_cli_argument_group"):
302288
group = parser.add_argument_group(title=f"{plugin_id} plugin")

src/mdformat/plugins.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,6 @@ class ParserExtensionInterface(Protocol):
5151
# (optional)
5252
POSTPROCESSORS: Mapping[str, Postprocess]
5353

54-
@staticmethod
55-
def add_cli_options(parser: argparse.ArgumentParser) -> None:
56-
"""DEPRECATED - use `add_cli_argument_group` instead.
57-
58-
Add options to the mdformat CLI, to be stored in
59-
mdit.options["mdformat"] (optional)
60-
"""
61-
6254
@staticmethod
6355
def add_cli_argument_group(group: argparse._ArgumentGroup) -> None:
6456
"""Add an argument group to mdformat CLI and add arguments to it.

tests/test_plugins.py

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -172,39 +172,6 @@ def test_table(monkeypatch):
172172
)
173173

174174

175-
class ExamplePluginWithCli:
176-
"""A plugin that adds CLI options."""
177-
178-
@staticmethod
179-
def update_mdit(mdit: MarkdownIt):
180-
mdit.enable("table")
181-
182-
@staticmethod
183-
def add_cli_options(parser: argparse.ArgumentParser) -> None:
184-
parser.add_argument("--o1", type=str)
185-
parser.add_argument("--o2", type=str, default="a")
186-
parser.add_argument("--o3", dest="arg_name", type=int)
187-
188-
189-
def test_cli_options(monkeypatch, tmp_path):
190-
"""Test that CLI arguments added by plugins are correctly added to the
191-
options dict."""
192-
monkeypatch.setitem(PARSER_EXTENSIONS, "table", ExamplePluginWithCli)
193-
file_path = tmp_path / "test_markdown.md"
194-
file_path.touch()
195-
196-
with patch.object(MDRenderer, "render", return_value="") as mock_render:
197-
assert run((str(file_path), "--o1", "other", "--o3", "4")) == 0
198-
199-
(call_,) = mock_render.call_args_list
200-
posargs = call_[0]
201-
# Options is the second positional arg of MDRender.render
202-
opts = posargs[1]
203-
assert opts["mdformat"]["o1"] == "other"
204-
assert opts["mdformat"]["o2"] == "a"
205-
assert opts["mdformat"]["arg_name"] == 4
206-
207-
208175
class ExamplePluginWithGroupedCli:
209176
"""A plugin that adds CLI options."""
210177

0 commit comments

Comments
 (0)