Skip to content

Commit 0da426f

Browse files
Remove redundant options documentation and improve formatting (#6665)
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent a5ca674 commit 0da426f

File tree

8 files changed

+425
-1407
lines changed

8 files changed

+425
-1407
lines changed

doc/exts/pylint_extensions.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ def builder_inited(app: Optional[Sphinx]) -> None:
8383
if i == max_len - 1:
8484
# Remove the \n\n at the end of the file
8585
j = -3
86-
print(checker.get_full_documentation(**information)[:j], file=stream)
86+
print(
87+
checker.get_full_documentation(**information, show_options=False)[:j],
88+
file=stream,
89+
)
8790

8891

8992
def get_plugins_info(linter, doc_files):

doc/exts/pylint_features.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def builder_inited(app: Optional[Sphinx]) -> None:
3636
3737
"""
3838
)
39-
print_full_documentation(linter, stream)
39+
print_full_documentation(linter, stream, False)
4040

4141

4242
def setup(app):

doc/exts/pylint_options.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@ def _get_all_options(linter: PyLinter) -> OptionsDataDict:
6666
def _create_checker_section(
6767
checker: str, options: list[OptionsData], linter: PyLinter
6868
) -> str:
69-
checker_string = get_rst_title(f"``{checker.capitalize()}`` Checker", "^")
69+
checker_string = f".. _{checker}-options:\n\n"
70+
checker_string += get_rst_title(f"``{checker.capitalize()}`` **Checker**", "-")
71+
7072
toml_doc = tomlkit.document()
7173
pylint_tool_table = tomlkit.table(is_super_table=True)
7274
toml_doc.add(tomlkit.key(["tool", "pylint"]), pylint_tool_table)
@@ -75,11 +77,11 @@ def _create_checker_section(
7577

7678
for option in sorted(options, key=lambda x: x.name):
7779
checker_string += get_rst_title(f"--{option.name}", '"')
78-
checker_string += f"\nDescription:\n *{option.optdict.get('help')}*\n\n"
80+
checker_string += f"*{option.optdict.get('help')}*\n\n"
7981
if option.optdict.get("default") == "":
80-
checker_string += 'Default:\n ``""``\n\n\n'
82+
checker_string += '**Default:** ``""``\n\n\n'
8183
else:
82-
checker_string += f"Default:\n ``{option.optdict.get('default')}``\n\n\n"
84+
checker_string += f"**Default:** ``{option.optdict.get('default')}``\n\n\n"
8385

8486
# Start adding the option to the toml example
8587
if option.optdict.get("hide_from_config_file"):
@@ -138,13 +140,13 @@ def _write_options_page(options: OptionsDataDict, linter: PyLinter) -> None:
138140
".. This file is auto-generated. Make any changes to the associated\n"
139141
".. docs extension in 'doc/exts/pylint_options.py'.\n\n"
140142
".. _all-options:",
141-
get_rst_title("Standard Checkers:", "^"),
143+
get_rst_title("Standard Checkers", "^"),
142144
]
143145
found_extensions = False
144146

145147
for checker, checker_options in options.items():
146148
if not found_extensions and checker_options[0].extension:
147-
sections.append(get_rst_title("Extensions:", "^"))
149+
sections.append(get_rst_title("Extensions", "^"))
148150
found_extensions = True
149151
sections.append(_create_checker_section(checker, checker_options, linter))
150152

doc/user_guide/checkers/extensions.rst

+6-62
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ Broad Try Clause checker
4242
This checker is provided by ``pylint.extensions.broad_try_clause``.
4343
Verbatim name of the checker is ``broad_try_clause``.
4444

45-
Broad Try Clause checker Options
46-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
47-
:max-try-statements:
48-
Maximum number of statements allowed in a try clause
49-
50-
Default: ``1``
45+
See also :ref:`broad_try_clause checker's options' documentation <broad_try_clause-options>`
5146

5247
Broad Try Clause checker Messages
5348
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -69,12 +64,7 @@ Checkers that can improve code consistency.
6964
As such they don't necessarily provide a performance benefit and
7065
are often times opinionated.
7166

72-
Code Style checker Options
73-
^^^^^^^^^^^^^^^^^^^^^^^^^^
74-
:max-line-length-suggestions:
75-
Max line length for which to sill emit suggestions. Used to prevent optional
76-
suggestions which would get split by a code formatter (e.g., black). Will
77-
default to the setting for ``max-line-length``.
67+
See also :ref:`code_style checker's options' documentation <code_style-options>`
7868

7969
Code Style checker Messages
8070
^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -202,12 +192,7 @@ you can use the ``bad-functions`` option::
202192
$ pylint a.py --load-plugins=pylint.extensions.bad_builtin --bad-functions=apply,reduce
203193
...
204194

205-
Deprecated Builtins checker Options
206-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
207-
:bad-functions:
208-
List of builtins function names that should not be used, separated by a comma
209-
210-
Default: ``map,filter``
195+
See also :ref:`deprecated_builtins checker's options' documentation <deprecated_builtins-options>`
211196

212197
Deprecated Builtins checker Messages
213198
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -265,12 +250,7 @@ higher than a preestablished value, which can be controlled through the
265250
$ pylint a.py --load-plugins=pylint.extensions.mccabe --max-complexity=50
266251
$
267252

268-
Design checker Options
269-
^^^^^^^^^^^^^^^^^^^^^^
270-
:max-complexity:
271-
McCabe complexity cyclomatic threshold
272-
273-
Default: ``10``
253+
See also :ref:`design checker's options' documentation <design-options>`
274254

275255
Design checker Messages
276256
^^^^^^^^^^^^^^^^^^^^^^^
@@ -550,33 +530,7 @@ docstring defining the interface, e.g. a superclass method, after "see"::
550530
Naming inconsistencies in existing parameter and their type documentations are
551531
still detected.
552532

553-
Parameter Documentation checker Options
554-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
555-
:accept-no-param-doc:
556-
Whether to accept totally missing parameter documentation in the docstring of
557-
a function that has parameters.
558-
559-
Default: ``yes``
560-
:accept-no-raise-doc:
561-
Whether to accept totally missing raises documentation in the docstring of a
562-
function that raises an exception.
563-
564-
Default: ``yes``
565-
:accept-no-return-doc:
566-
Whether to accept totally missing return documentation in the docstring of a
567-
function that returns a statement.
568-
569-
Default: ``yes``
570-
:accept-no-yields-doc:
571-
Whether to accept totally missing yields documentation in the docstring of a
572-
generator.
573-
574-
Default: ``yes``
575-
:default-docstring-type:
576-
If the docstring type cannot be guessed the specified docstring type will be
577-
used.
578-
579-
Default: ``default``
533+
See also :ref:`parameter_documentation checker's options' documentation <parameter_documentation-options>`
580534

581535
Parameter Documentation checker Messages
582536
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -667,17 +621,7 @@ Typing checker Documentation
667621
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
668622
Find issue specifically related to type annotations.
669623

670-
Typing checker Options
671-
^^^^^^^^^^^^^^^^^^^^^^
672-
:runtime-typing:
673-
Set to ``no`` if the app / library does **NOT** need to support runtime
674-
introspection of type annotations. If you use type annotations
675-
**exclusively** for type checking of an application, you're probably fine.
676-
For libraries, evaluate if some users what to access the type hints at
677-
runtime first, e.g., through ``typing.get_type_hints``. Applies to Python
678-
versions 3.7 - 3.9
679-
680-
Default: ``yes``
624+
See also :ref:`typing checker's options' documentation <typing-options>`
681625

682626
Typing checker Messages
683627
^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)