Skip to content

Commit e348d7b

Browse files
[refactor] Better link and toc definition for overview of messages
1 parent f906a22 commit e348d7b

File tree

5 files changed

+579
-561
lines changed

5 files changed

+579
-561
lines changed

doc/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"user_guide/ide-integration": "installation.html",
5454
"messages/index": "user_guide/messages/index.html",
5555
"messages/messages_introduction": "user_guide/messages/index.html",
56+
"messages/messages_list": "user_guide/messages/messages_overview.html",
5657
"user_guide/message-control": "user_guide/messages/message-control.html",
5758
}
5859

doc/exts/pylint_messages.py

+18-13
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ def _write_single_message_page(category_dir: Path, message: MessageData) -> None
230230
stream.write(
231231
f"""
232232
.. note::
233-
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}`.
233+
This message is emitted by an optional checker which requires the ``{message.checker_module_name}``
234+
plugin to be loaded. See: :ref:`{message.checker_module_name}`.
234235
235236
"""
236237
)
@@ -244,22 +245,24 @@ def _write_messages_list_page(
244245
messages_dict: MessagesDict, old_messages_dict: OldMessagesDict
245246
) -> None:
246247
"""Create or overwrite the page with the list of all messages."""
247-
messages_file = os.path.join(PYLINT_MESSAGES_PATH, "messages_list.rst")
248+
messages_file = os.path.join(PYLINT_MESSAGES_PATH, "messages_overview.rst")
248249
with open(messages_file, "w", encoding="utf-8") as stream:
249250
# Write header of file
251+
title = "Messages overview"
250252
stream.write(
251-
f""".. _messages-list:
253+
f"""
254+
.. _messages-overview:
252255
253-
{get_rst_title("Overview of all Pylint messages", "=")}
256+
{"#" * len(title)}
257+
{get_rst_title(title, "#")}
254258
..
255259
NOTE This file is auto-generated. Make any changes to the associated
256-
docs extension in 'pylint_messages.py'.
260+
docs extension in 'doc/exts/pylint_messages.py'.
257261
258262
Pylint can emit the following messages:
259263
260264
"""
261265
)
262-
263266
# Iterate over tuple to keep same order
264267
for category in (
265268
"fatal",
@@ -272,15 +275,19 @@ def _write_messages_list_page(
272275
messages = sorted(messages_dict[category], key=lambda item: item.name)
273276
old_messages = sorted(old_messages_dict[category], key=lambda item: item[0])
274277
messages_string = "".join(
275-
f" {category}/{message.name}.rst\n" for message in messages
278+
f" {category}/{message.name}\n" for message in messages
276279
)
277280
old_messages_string = "".join(
278-
f" {category}/{old_message[0]}.rst\n" for old_message in old_messages
281+
f" {category}/{old_message[0]}\n" for old_message in old_messages
279282
)
280283

281-
# Write list per category
284+
# Write list per category. We need the '-category' suffix in the reference
285+
# because 'fatal' is also a message's symbol
282286
stream.write(
283-
f"""{get_rst_title(category.capitalize(), "-")}
287+
f"""
288+
.. _{category.lower()}-category:
289+
290+
{get_rst_title(category.capitalize(), "*")}
284291
All messages in the {category} category:
285292
286293
.. toctree::
@@ -294,9 +301,7 @@ def _write_messages_list_page(
294301
:maxdepth: 1
295302
:titlesonly:
296303
297-
{old_messages_string}
298-
299-
"""
304+
{old_messages_string}"""
300305
)
301306

302307

doc/user_guide/messages/index.rst

+11-9
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,23 @@ Messages
88
:maxdepth: 2
99
:hidden:
1010

11-
12-
messages_list.rst
11+
messages_overview.rst
1312
message-control.rst
1413

14+
Messages categories
15+
===================
16+
1517
Pylint can emit various messages. These are categorized according
1618
to categories corresponding to bit-encoded exit codes:
1719

18-
* :ref:`Fatal` (1)
19-
* :ref:`Error` (2)
20-
* :ref:`Warning` (4)
21-
* :ref:`Convention` (8)
22-
* :ref:`Refactor` (16)
23-
* :ref:`Information` (NA)
20+
* :ref:`Fatal <fatal-category>` (1)
21+
* :ref:`Error <error-category>` (2)
22+
* :ref:`Warning <warning-category>` (4)
23+
* :ref:`Convention <convention-category>` (8)
24+
* :ref:`Refactor <refactor-category>` (16)
25+
* :ref:`Information <information-category>` (NA)
2426

25-
A list of these messages can be found in :ref:`messages-list`
27+
An overview of these messages can be found in :ref:`messages-overview`
2628

2729
Disabling messages
2830
==================

0 commit comments

Comments
 (0)