summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2022-06-06 10:51:00 +0200
committerGitHub <noreply@github.com>2022-06-06 10:51:00 +0200
commitaec8eff59efa55d6c0456f518b16732c1d2d5167 (patch)
tree6f1cdbc5edfc0f589c92f7d6a85059a8e86b3118
parent0da426fd3750de02a1cf358c034e3f888c8e6bee (diff)
downloadpylint-git-aec8eff59efa55d6c0456f518b16732c1d2d5167.tar.gz
[doc] Fix the assert for placeholders following #6839 (#6873)
-rw-r--r--doc/exts/pylint_messages.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/doc/exts/pylint_messages.py b/doc/exts/pylint_messages.py
index 3ca0f467a..3196b0b2c 100644
--- a/doc/exts/pylint_messages.py
+++ b/doc/exts/pylint_messages.py
@@ -78,12 +78,24 @@ def _get_message_data(data_path: Path) -> Tuple[str, str, str, str]:
related = _get_titled_rst(
title="Related links", text=_get_rst_as_str(related_rst_path)
)
- assert (not bad_code and not related) or (
- "placeholder" not in good_code and "help us make the doc better" not in details
- ), "Please remove placeholders if you completed the documentation"
+ _check_placeholders(bad_code, details, good_py_path, related)
return good_code, bad_code, details, related
+def _check_placeholders(
+ bad_code: str, details: str, good_py_path: Path, related: str
+) -> None:
+ if bad_code or related:
+ placeholder_details = "help us make the doc better" in details
+ with open(good_py_path) as f:
+ placeholder_good = "placeholder" in f.read()
+ assert_msg = (
+ f"Please remove placeholders in '{good_py_path.parent}' "
+ f"as you started completing the documentation"
+ )
+ assert not placeholder_good and not placeholder_details, assert_msg
+
+
def _get_titled_rst(title: str, text: str) -> str:
"""Return rst code with a title if there is anything in the section."""
return f"**{title}:**\n\n{text}" if text else ""