Skip to content

Commit 8a2f9f5

Browse files
[3.14] gh-126031: Mark argparse parameter headings as code (GH-160632) (#160764)
gh-126031: Mark argparse parameter headings as code (GH-160632) (cherry picked from commit d54c2d8) Co-authored-by: techi101 <niteshkumar88449@gmail.com>
1 parent f336df0 commit 8a2f9f5

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 list the permissible
@@ -620,8 +620,8 @@ keyword argument::
620620
.. versionadded:: 3.14
621621

622622

623-
color
624-
^^^^^
623+
``color``
624+
^^^^^^^^^
625625

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

698698
.. _`name or flags`:
699699

700-
name or flags
701-
^^^^^^^^^^^^^
700+
``name`` or ``flags``
701+
^^^^^^^^^^^^^^^^^^^^^
702702

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

752752
.. _action:
753753

754-
action
755-
^^^^^^
754+
``action``
755+
^^^^^^^^^^
756756

757757
:class:`ArgumentParser` objects associate command-line arguments with actions. These
758758
actions can do just about anything with the command-line arguments associated with
@@ -889,8 +889,8 @@ For more details, see :class:`Action`.
889889

890890
.. _nargs:
891891

892-
nargs
893-
^^^^^
892+
``nargs``
893+
^^^^^^^^^
894894

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

979979
.. _const:
980980

981-
const
982-
^^^^^
981+
``const``
982+
^^^^^^^^^
983983

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

10071007
.. _default:
10081008

1009-
default
1010-
^^^^^^^
1009+
``default``
1010+
^^^^^^^^^^^
10111011

10121012
All optional arguments and some positional arguments may be omitted at the
10131013
command line. The ``default`` keyword argument of
@@ -1076,8 +1076,8 @@ command-line argument was not present::
10761076

10771077
.. _argparse-type:
10781078

1079-
type
1080-
^^^^
1079+
``type``
1080+
^^^^^^^^
10811081

10821082
By default, the parser reads command-line arguments in as simple
10831083
strings. However, quite often the command-line string should instead be
@@ -1155,8 +1155,8 @@ using the choices_ keyword instead.
11551155

11561156
.. _choices:
11571157

1158-
choices
1159-
^^^^^^^
1158+
``choices``
1159+
^^^^^^^^^^^
11601160

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

11971197
.. _required:
11981198

1199-
required
1200-
^^^^^^^^
1199+
``required``
1200+
^^^^^^^^^^^^
12011201

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

12251225
.. _help:
12261226

1227-
help
1228-
^^^^
1227+
``help``
1228+
^^^^^^^^
12291229

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

12671267
.. _metavar:
12681268

1269-
metavar
1270-
^^^^^^^
1269+
``metavar``
1270+
^^^^^^^^^^^
12711271

12721272
When :class:`ArgumentParser` generates help messages, it needs some way to refer
12731273
to each expected argument. By default, :class:`!ArgumentParser` objects use the dest_
@@ -1332,8 +1332,8 @@ arguments::
13321332

13331333
.. _dest:
13341334

1335-
dest
1336-
^^^^
1335+
``dest``
1336+
^^^^^^^^
13371337

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

13791379
.. _deprecated:
13801380

1381-
deprecated
1382-
^^^^^^^^^^
1381+
``deprecated``
1382+
^^^^^^^^^^^^^^
13831383

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

0 commit comments

Comments
 (0)