Skip to content

Commit

Permalink
Code review
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord committed Dec 14, 2021
1 parent 4e464ab commit 3768ddc
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions doc/exts/pylint_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import os
from collections import defaultdict
from pathlib import Path
from typing import DefaultDict, Dict, List, NamedTuple, Optional, Tuple

from sphinx.application import Sphinx
Expand All @@ -16,12 +17,12 @@
from pylint.message import MessageDefinition
from pylint.utils import get_rst_title

# PACKAGE/docs/exts/pylint_extensions.py --> PACKAGE/
PYLINT_BASE_PATH = os.path.dirname(
os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
)
PYLINT_BASE_PATH = Path(__file__).resolve().parent.parent.parent
"""Base path to the project folder"""

PYLINT_MESSAGES_PATH = os.path.join(PYLINT_BASE_PATH, "doc", "messages")
"""Path to the messages documentation folder"""


MSG_TYPES_DOC = {k: v if v != "info" else "information" for k, v in MSG_TYPES.items()}

Expand Down Expand Up @@ -88,7 +89,7 @@ def _get_all_messages(
def _write_message_page(messages_dict: MessagesDict) -> None:
"""Create or overwrite the file for each message."""
for category, messages in messages_dict.items():
category_dir = os.path.join(PYLINT_BASE_PATH, "doc", "messages", category)
category_dir = os.path.join(PYLINT_MESSAGES_PATH, category)
if not os.path.exists(category_dir):
os.makedirs(category_dir)
for message in messages:
Expand All @@ -115,9 +116,7 @@ def _write_messages_list_page(
messages_dict: MessagesDict, old_messages_dict: OldMessagesDict
) -> None:
"""Create or overwrite the page with the list of all messages."""
messages_file = os.path.join(
PYLINT_BASE_PATH, "doc", "messages", "messages_list.rst"
)
messages_file = os.path.join(PYLINT_MESSAGES_PATH, "messages_list.rst")
with open(messages_file, "w", encoding="utf-8") as stream:
# Write header of file
stream.write(
Expand Down Expand Up @@ -172,7 +171,7 @@ def _write_messages_list_page(
def _write_redirect_pages(old_messages: OldMessagesDict) -> None:
"""Create redirect pages for old-messages."""
for category, old_names in old_messages.items():
category_dir = os.path.join(PYLINT_BASE_PATH, "doc", "messages", category)
category_dir = os.path.join(PYLINT_MESSAGES_PATH, category)
if not os.path.exists(category_dir):
os.makedirs(category_dir)
for old_name, new_names in old_names.items():
Expand Down

0 comments on commit 3768ddc

Please sign in to comment.