Skip to content

Commit 29064d6

Browse files
[3.15] gh-126031: Mark argparse parameter headings as code (GH-160632) (#160763)
gh-126031: Mark argparse parameter headings as code (GH-160632) (cherry picked from commit d54c2d8) Co-authored-by: techi101 <niteshkumar88449@gmail.com>
1 parent 5c7473e commit 29064d6

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
@@ -893,8 +893,8 @@ For more details, see :class:`Action`.
893893

894894
.. _nargs:
895895

896-
nargs
897-
^^^^^
896+
``nargs``
897+
^^^^^^^^^
898898

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

983983
.. _const:
984984

985-
const
986-
^^^^^
985+
``const``
986+
^^^^^^^^^
987987

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

10111011
.. _default:
10121012

1013-
default
1014-
^^^^^^^
1013+
``default``
1014+
^^^^^^^^^^^
10151015

10161016
All optional arguments and some positional arguments may be omitted at the
10171017
command line. The ``default`` keyword argument of
@@ -1080,8 +1080,8 @@ command-line argument was not present::
10801080

10811081
.. _argparse-type:
10821082

1083-
type
1084-
^^^^
1083+
``type``
1084+
^^^^^^^^
10851085

10861086
By default, the parser reads command-line arguments in as simple
10871087
strings. However, quite often the command-line string should instead be
@@ -1159,8 +1159,8 @@ using the choices_ keyword instead.
11591159

11601160
.. _choices:
11611161

1162-
choices
1163-
^^^^^^^
1162+
``choices``
1163+
^^^^^^^^^^^
11641164

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

12011201
.. _required:
12021202

1203-
required
1204-
^^^^^^^^
1203+
``required``
1204+
^^^^^^^^^^^^
12051205

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

12291229
.. _help:
12301230

1231-
help
1232-
^^^^
1231+
``help``
1232+
^^^^^^^^
12331233

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

12711271
.. _metavar:
12721272

1273-
metavar
1274-
^^^^^^^
1273+
``metavar``
1274+
^^^^^^^^^^^
12751275

12761276
When :class:`ArgumentParser` generates help messages, it needs some way to refer
12771277
to each expected argument. By default, :class:`!ArgumentParser` objects use the dest_
@@ -1336,8 +1336,8 @@ arguments::
13361336

13371337
.. _dest:
13381338

1339-
dest
1340-
^^^^
1339+
``dest``
1340+
^^^^^^^^
13411341

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

13921392
.. _deprecated:
13931393

1394-
deprecated
1395-
^^^^^^^^^^
1394+
``deprecated``
1395+
^^^^^^^^^^^^^^
13961396

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

0 commit comments

Comments
 (0)