summaryrefslogtreecommitdiff
path: root/doc/exts
diff options
context:
space:
mode:
authorPierre Sassoulas <pierre.sassoulas@gmail.com>2022-05-16 10:24:25 +0200
committerPierre Sassoulas <pierre.sassoulas@gmail.com>2022-05-16 12:21:17 +0200
commitb639956f8505d98e16bdf93ff2946a160afc2f3d (patch)
tree7213dad530dc1b4c34c21a9aa6e3aa31ad2b5eb6 /doc/exts
parent71f93af8cc1bc68021897f62c8a879f723af0355 (diff)
downloadpylint-git-b639956f8505d98e16bdf93ff2946a160afc2f3d.tar.gz
[refactor] Create a function for writting a message's .rst
Diffstat (limited to 'doc/exts')
-rw-r--r--doc/exts/pylint_messages.py36
1 files changed, 20 insertions, 16 deletions
diff --git a/doc/exts/pylint_messages.py b/doc/exts/pylint_messages.py
index b9cfa5346..f51696037 100644
--- a/doc/exts/pylint_messages.py
+++ b/doc/exts/pylint_messages.py
@@ -177,13 +177,17 @@ def _write_message_page(messages_dict: MessagesDict) -> None:
if not category_dir.exists():
category_dir.mkdir(parents=True, exist_ok=True)
for message in messages:
- checker_module_rel_path = os.path.relpath(
- message.checker_module_path, PYLINT_BASE_PATH
- )
- messages_file = os.path.join(category_dir, f"{message.name}.rst")
- with open(messages_file, "w", encoding="utf-8") as stream:
- stream.write(
- f""".. _{message.name}:
+ _write_single_message_page(category_dir, message)
+
+
+def _write_single_message_page(category_dir: Path, message: MessageData) -> None:
+ checker_module_rel_path = os.path.relpath(
+ message.checker_module_path, PYLINT_BASE_PATH
+ )
+ messages_file = os.path.join(category_dir, f"{message.name}.rst")
+ with open(messages_file, "w", encoding="utf-8") as stream:
+ stream.write(
+ f""".. _{message.name}:
{get_rst_title(f"{message.name} / {message.id}", "=")}
**Message emitted:**
@@ -199,19 +203,19 @@ def _write_message_page(messages_dict: MessagesDict) -> None:
{message.details}
{message.related_links}
"""
- )
- if message.checker_module_name.startswith("pylint.extensions."):
- stream.write(
- f"""
+ )
+ if message.checker_module_name.startswith("pylint.extensions."):
+ stream.write(
+ f"""
.. note::
This message is emitted by an optional checker which requires the ``{message.checker_module_name}`` plugin to be loaded. See: :ref:`{message.checker_module_name}`.
"""
- )
- checker_url = f"https://github.com/PyCQA/pylint/blob/main/{checker_module_rel_path}"
- stream.write(
- f"Created by the `{message.checker} <{checker_url}>`__ checker."
- )
+ )
+ checker_url = (
+ f"https://github.com/PyCQA/pylint/blob/main/{checker_module_rel_path}"
+ )
+ stream.write(f"Created by the `{message.checker} <{checker_url}>`__ checker.")
def _write_messages_list_page(