Skip to content

Commit d54c2d8

Browse files
authored
gh-126031: Mark argparse parameter headings as code (#160632)
1 parent 085d366 commit d54c2d8

1 file changed

Lines changed: 54 additions & 54 deletions

File tree

‎Doc/library/argparse.rst‎

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ The following sections describe how each of these are used.
139139

140140
.. _prog:
141141

142-
prog
143-
^^^^
142+
``prog``
143+
^^^^^^^^
144144

145145

146146
By default, :class:`ArgumentParser` calculates the name of the program
@@ -185,8 +185,8 @@ specifier.
185185
The default ``prog`` value now reflects how ``__main__`` was actually executed,
186186
rather than always being ``os.path.basename(sys.argv[0])``.
187187

188-
usage
189-
^^^^^
188+
``usage``
189+
^^^^^^^^^
190190

191191
By default, :class:`ArgumentParser` calculates the usage message from the
192192
arguments it contains. The default message can be overridden with the
@@ -217,8 +217,8 @@ usage information across subparsers.
217217

218218
.. _description:
219219

220-
description
221-
^^^^^^^^^^^
220+
``description``
221+
^^^^^^^^^^^^^^^
222222

223223
Most calls to the :class:`ArgumentParser` constructor will use the
224224
``description=`` keyword argument. This argument gives a brief description of
@@ -230,8 +230,8 @@ By default, the description will be line-wrapped so that it fits within the
230230
given space. To change this behavior, see the formatter_class_ argument.
231231

232232

233-
epilog
234-
^^^^^^
233+
``epilog``
234+
^^^^^^^^^^
235235

236236
Some programs like to display additional description of the program after the
237237
description of the arguments. Such text can be specified using the ``epilog=``
@@ -255,8 +255,8 @@ line-wrapped, but this behavior can be adjusted with the formatter_class_
255255
argument to :class:`ArgumentParser`.
256256

257257

258-
parents
259-
^^^^^^^
258+
``parents``
259+
^^^^^^^^^^^
260260

261261
Sometimes, several parsers share a common set of arguments. Rather than
262262
repeating the definitions of these arguments, a single parser with all the
@@ -290,8 +290,8 @@ and one in the child) and raise an error.
290290

291291
.. _formatter_class:
292292

293-
formatter_class
294-
^^^^^^^^^^^^^^^
293+
``formatter_class``
294+
^^^^^^^^^^^^^^^^^^^
295295

296296
:class:`ArgumentParser` objects allow the help formatting to be customized by
297297
specifying an alternate formatting class. Currently, there are four such
@@ -396,8 +396,8 @@ as the regular formatter does)::
396396
--foo int
397397

398398

399-
prefix_chars
400-
^^^^^^^^^^^^
399+
``prefix_chars``
400+
^^^^^^^^^^^^^^^^
401401

402402
Most command-line options will use ``-`` as the prefix, e.g. ``-f/--foo``.
403403
Parsers that need to support different or additional prefix
@@ -416,8 +416,8 @@ characters that does not include ``-`` will cause ``-f/--foo`` options to be
416416
disallowed.
417417

418418

419-
fromfile_prefix_chars
420-
^^^^^^^^^^^^^^^^^^^^^
419+
``fromfile_prefix_chars``
420+
^^^^^^^^^^^^^^^^^^^^^^^^^
421421

422422
Sometimes, when dealing with a particularly long argument list, it
423423
may make sense to keep the list of arguments in a file rather than typing it out
@@ -458,8 +458,8 @@ arguments will never be treated as file references.
458458
Arguments file should be encoded in UTF-8 instead of ANSI Codepage on Windows.
459459

460460

461-
argument_default
462-
^^^^^^^^^^^^^^^^
461+
``argument_default``
462+
^^^^^^^^^^^^^^^^^^^^
463463

464464
Generally, argument defaults are specified either by passing a default to
465465
:meth:`~ArgumentParser.add_argument` or by calling the
@@ -480,8 +480,8 @@ calls, we supply ``argument_default=SUPPRESS``::
480480

481481
.. _allow_abbrev:
482482

483-
allow_abbrev
484-
^^^^^^^^^^^^
483+
``allow_abbrev``
484+
^^^^^^^^^^^^^^^^
485485

486486
Normally, when you pass an argument list to the
487487
:meth:`~ArgumentParser.parse_args` method of an :class:`ArgumentParser`,
@@ -499,8 +499,8 @@ This feature can be disabled by setting ``allow_abbrev`` to ``False``::
499499
.. versionadded:: 3.5
500500

501501

502-
conflict_handler
503-
^^^^^^^^^^^^^^^^
502+
``conflict_handler``
503+
^^^^^^^^^^^^^^^^^^^^
504504

505505
:class:`ArgumentParser` objects do not allow two actions with the same option
506506
string. By default, :class:`ArgumentParser` objects raise an exception if an
@@ -536,8 +536,8 @@ action is retained as the ``-f`` action, because only the ``--foo`` option
536536
string was overridden.
537537

538538

539-
add_help
540-
^^^^^^^^
539+
``add_help``
540+
^^^^^^^^^^^^
541541

542542
By default, :class:`ArgumentParser` objects add an option which simply displays
543543
the parser's help message. If ``-h`` or ``--help`` is supplied at the command
@@ -569,8 +569,8 @@ the help options::
569569
+h, ++help show this help message and exit
570570

571571

572-
exit_on_error
573-
^^^^^^^^^^^^^
572+
``exit_on_error``
573+
^^^^^^^^^^^^^^^^^
574574

575575
Normally, when you pass an invalid argument list to the :meth:`~ArgumentParser.parse_args`
576576
method of an :class:`ArgumentParser`, it will print a *message* to :data:`sys.stderr` and exit with a status
@@ -591,8 +591,8 @@ If the user would like to catch errors manually, the feature can be enabled by s
591591

592592
.. versionadded:: 3.9
593593

594-
suggest_on_error
595-
^^^^^^^^^^^^^^^^
594+
``suggest_on_error``
595+
^^^^^^^^^^^^^^^^^^^^
596596

597597
By default, when a user passes an invalid argument choice or subparser name,
598598
:class:`ArgumentParser` will exit with error info and provide suggestions for
@@ -613,8 +613,8 @@ You can disable suggestions by setting ``suggest_on_error`` to ``False``.
613613
.. versionchanged:: 3.15
614614
Changed default value of ``suggest_on_error`` from ``False`` to ``True``.
615615

616-
color
617-
^^^^^
616+
``color``
617+
^^^^^^^^^
618618

619619
By default, the help message is printed in color using `ANSI escape sequences
620620
<https://en.wikipedia.org/wiki/ANSI_escape_code>`__.
@@ -701,8 +701,8 @@ The following sections describe how each of these are used.
701701

702702
.. _`name or flags`:
703703

704-
name or flags
705-
^^^^^^^^^^^^^
704+
``name`` or ``flags``
705+
^^^^^^^^^^^^^^^^^^^^^
706706

707707
The :meth:`~ArgumentParser.add_argument` method must know whether an optional
708708
argument, like ``-f`` or ``--foo``, or a positional argument, like a list of
@@ -755,8 +755,8 @@ the upper-cased name. For example::
755755

756756
.. _action:
757757

758-
action
759-
^^^^^^
758+
``action``
759+
^^^^^^^^^^
760760

761761
:class:`ArgumentParser` objects associate command-line arguments with actions. These
762762
actions can do just about anything with the command-line arguments associated with
@@ -897,8 +897,8 @@ For more details, see :class:`Action`.
897897

898898
.. _nargs:
899899

900-
nargs
901-
^^^^^
900+
``nargs``
901+
^^^^^^^^^
902902

903903
:class:`ArgumentParser` objects usually associate a single command-line argument with a
904904
single action to be taken. The ``nargs`` keyword argument associates a
@@ -986,8 +986,8 @@ Actions that do not consume command-line arguments (e.g.
986986

987987
.. _const:
988988

989-
const
990-
^^^^^
989+
``const``
990+
^^^^^^^^^
991991

992992
The ``const`` argument of :meth:`~ArgumentParser.add_argument` is used to hold
993993
constant values that are not read from the command line but are required for
@@ -1014,8 +1014,8 @@ the various :class:`ArgumentParser` actions. The two most common uses of it are
10141014

10151015
.. _default:
10161016

1017-
default
1018-
^^^^^^^
1017+
``default``
1018+
^^^^^^^^^^^
10191019

10201020
All optional arguments and some positional arguments may be omitted at the
10211021
command line. The ``default`` keyword argument of
@@ -1084,8 +1084,8 @@ command-line argument was not present::
10841084

10851085
.. _argparse-type:
10861086

1087-
type
1088-
^^^^
1087+
``type``
1088+
^^^^^^^^
10891089

10901090
By default, the parser reads command-line arguments in as simple
10911091
strings. However, quite often the command-line string should instead be
@@ -1163,8 +1163,8 @@ using the choices_ keyword instead.
11631163

11641164
.. _choices:
11651165

1166-
choices
1167-
^^^^^^^
1166+
``choices``
1167+
^^^^^^^^^^^
11681168

11691169
Some command-line arguments should be selected from a restricted set of values.
11701170
These can be handled by passing a sequence object as the *choices* keyword
@@ -1204,8 +1204,8 @@ many choices), just specify an explicit metavar_.
12041204

12051205
.. _required:
12061206

1207-
required
1208-
^^^^^^^^
1207+
``required``
1208+
^^^^^^^^^^^^
12091209

12101210
In general, the :mod:`!argparse` module assumes that flags like ``-f`` and ``--bar``
12111211
indicate *optional* arguments, which can always be omitted at the command line.
@@ -1232,8 +1232,8 @@ present at the command line.
12321232

12331233
.. _help:
12341234

1235-
help
1236-
^^^^
1235+
``help``
1236+
^^^^^^^^
12371237

12381238
The ``help`` value is a string containing a brief description of the argument.
12391239
When a user requests help (usually by using ``-h`` or ``--help`` at the
@@ -1274,8 +1274,8 @@ setting the ``help`` value to ``argparse.SUPPRESS``::
12741274

12751275
.. _metavar:
12761276

1277-
metavar
1278-
^^^^^^^
1277+
``metavar``
1278+
^^^^^^^^^^^
12791279

12801280
When :class:`ArgumentParser` generates help messages, it needs some way to refer
12811281
to each expected argument. By default, :class:`!ArgumentParser` objects use the dest_
@@ -1340,8 +1340,8 @@ arguments::
13401340

13411341
.. _dest:
13421342

1343-
dest
1344-
^^^^
1343+
``dest``
1344+
^^^^^^^^
13451345

13461346
Most :class:`ArgumentParser` actions add some value as an attribute of the
13471347
object returned by :meth:`~ArgumentParser.parse_args`. The name of this
@@ -1395,8 +1395,8 @@ strings* rather than ``dest`` names, see conflict_handler_.
13951395

13961396
.. _deprecated:
13971397

1398-
deprecated
1399-
^^^^^^^^^^
1398+
``deprecated``
1399+
^^^^^^^^^^^^^^
14001400

14011401
During a project's lifetime, some arguments may need to be removed from the
14021402
command line. Before removing them, you should inform

0 commit comments

Comments
 (0)