fix: indent docstring body in help paste output
Some checks failed
CI / gitleaks (push) Failing after 3s
CI / lint (push) Failing after 23s
CI / test (3.11) (push) Has been skipped
CI / test (3.12) (push) Has been skipped
CI / test (3.13) (push) Has been skipped
CI / build (push) Has been skipped

Command name stays flush-left, docstring lines indented 4 spaces.
Plugin descriptions in the full reference also indented under headers.
Adds test_help_paste_body_indented to verify formatting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
user
2026-02-23 23:12:10 +01:00
parent ef18915807
commit ecfa7cea39
2 changed files with 40 additions and 7 deletions

View File

@@ -130,10 +130,19 @@ def _cmd_no_doc():
pass
def _make_fp_module(url="https://paste.example.com/abc/raw"):
"""Create a fake flaskpaste module that returns a fixed URL."""
def _make_fp_module(url="https://paste.example.com/abc/raw", capture=None):
"""Create a fake flaskpaste module that returns a fixed URL.
If capture is a list, appended paste content is stored there.
"""
mod = types.ModuleType("flaskpaste")
mod.create_paste = lambda bot, text: url
def _create(bot, text):
if capture is not None:
capture.append(text)
return url
mod.create_paste = _create
return mod
@@ -227,3 +236,23 @@ class TestHelpCommand:
assert len(bot.replied) == 1
assert "!widget -- Manage widgets" in bot.replied[0]
assert "https://" not in bot.replied[0]
def test_help_paste_body_indented(self):
"""Paste body has command name flush-left, docstring indented."""
bot = _FakeBot()
pastes: list[str] = []
bot.registry._modules["flaskpaste"] = _make_fp_module(capture=pastes)
bot.registry.commands["widget"] = _FakeHandler(
name="widget", callback=_cmd_with_doc,
help="Manage widgets", plugin="widgets",
)
msg = _Msg(text="!help widget")
asyncio.run(_mod.cmd_help(bot, msg))
assert len(pastes) == 1
lines = pastes[0].split("\n")
# First line: command header, no indent
assert lines[0] == "!widget -- Manage widgets"
# Docstring lines are indented 4 spaces
for line in lines[1:]:
if line.strip():
assert line.startswith(" "), f"not indented: {line!r}"