Skip to content

Refactor prior to removing redundant options documentation #6682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pylint/config/arguments_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def options_by_section(

(section, [list of (optname, optdict, optvalue)])
"""
# TODO 3.0: Make this function private see
# https://github.com/PyCQA/pylint/pull/6665#discussion_r880143229
# It's only used in '_get_global_options_documentation'
warnings.warn(
"options_by_section has been deprecated. It will be removed "
"in a future release.",
Expand Down
34 changes: 19 additions & 15 deletions pylint/utils/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,31 @@ def _get_checkers_infos(linter: PyLinter) -> dict[str, dict[str, Any]]:
return by_checker


def _get_checkers_documentation(linter: PyLinter) -> str:
"""Get documentation for individual checkers."""
def _get_global_options_documentation(linter: PyLinter) -> str:
"""Get documentation for the main checker."""
result = get_rst_title("Pylint global options and switches", "-")
result += """
Pylint provides global options and switches.

"""
for checker in linter.get_checkers():
name = checker.name
if name == MAIN_CHECKER_NAME:
if checker.options:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
for section, options in checker.options_by_section():
if section is None:
title = "General options"
else:
title = f"{section.capitalize()} options"
result += get_rst_title(title, "~")
assert isinstance(options, list)
result += f"{get_rst_section(None, options)}\n"
if checker.name == MAIN_CHECKER_NAME and checker.options:
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
for section, options in checker.options_by_section():
if section is None:
title = "General options"
else:
title = f"{section.capitalize()} options"
result += get_rst_title(title, "~")
assert isinstance(options, list)
result += f"{get_rst_section(None, options)}\n"
return result


def _get_checkers_documentation(linter: PyLinter) -> str:
"""Get documentation for individual checkers."""
result = _get_global_options_documentation(linter)
result += get_rst_title("Pylint checkers' options and switches", "-")
result += """\

Expand Down