diff options
author | Pierre Sassoulas <pierre.sassoulas@gmail.com> | 2022-05-26 10:46:09 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-26 10:46:09 +0200 |
commit | 0f73bb6fc0347c27dcd2d9086f5f60403a9387c5 (patch) | |
tree | 9802679a8a407b775948db8e42524e323a85ad40 /doc/exts | |
parent | e9dbcf922d35b8023634cfa4d345d41e6cd5a385 (diff) | |
download | pylint-git-0f73bb6fc0347c27dcd2d9086f5f60403a9387c5.tar.gz |
Generate the data message directories with an advert for potential contributors (#6702)
Diffstat (limited to 'doc/exts')
-rw-r--r-- | doc/exts/pylint_messages.py | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/doc/exts/pylint_messages.py b/doc/exts/pylint_messages.py index 460f4c018..8bb96595e 100644 --- a/doc/exts/pylint_messages.py +++ b/doc/exts/pylint_messages.py @@ -61,12 +61,24 @@ def _register_all_checkers_and_extensions(linter: PyLinter) -> None: def _get_message_data(data_path: Path) -> Tuple[str, str, str, str]: """Get the message data from the specified path.""" good_code, bad_code, details, related = "", "", "", "" - + good_py_path = data_path / "good.py" + details_rst_path = data_path / "details.rst" if not data_path.exists(): - return good_code, bad_code, details, related - - if (data_path / "good.py").exists(): - with open(data_path / "good.py", encoding="utf-8") as file: + data_path.mkdir(parents=True) + with open(good_py_path, "w", encoding="utf-8") as file: + file.write( + """\ +# This is a placeholder for correct code for this message. +""" + ) + with open(details_rst_path, "w", encoding="utf-8") as file: + file.write( + """\ +You can help us make the doc better `by contributing <https://github.com/PyCQA/pylint/issues/5953>`_ ! +""" + ) + if good_py_path.exists(): + with open(good_py_path, encoding="utf-8") as file: file_content = file.readlines() indented_file_content = "".join(" " + i for i in file_content) good_code = f""" @@ -87,8 +99,8 @@ def _get_message_data(data_path: Path) -> Tuple[str, str, str, str]: {indented_file_content}""" - if (data_path / "details.rst").exists(): - with open(data_path / "details.rst", encoding="utf-8") as file: + if (details_rst_path).exists(): + with open(details_rst_path, encoding="utf-8") as file: file_content_string = file.read() details = f""" **Additional details:** @@ -102,7 +114,6 @@ def _get_message_data(data_path: Path) -> Tuple[str, str, str, str]: **Related links:** {file_content_string}""" - return good_code, bad_code, details, related |