8000 bpo-21150: add quick link/summary table to the top of argparse documentation by suhearsawho · Pull Request #12005 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-21150: add quick link/summary table to the top of argparse documentation #12005

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 8 commits into from
Apr 18, 2022
Prev Previous commit
Next Next commit
Changed core functionality table into sentences based on merwok's rec…
…ommendation
  • Loading branch information
suhearsawho committed Feb 24, 2019
commit 2d96d8313decb030ea13123e0541c3ef4d209804
16 changes: 11 additions & 5 deletions Doc/library/argparse.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@ Summary
Core Functionality
^^^^^^^^^^^^^^^^^^

.. csv-table::
:header: "Name", "Commonly Used Arguments", "Example"
The :mod:`argparse` module's support for command-line interfaces is built from the following:

":class:`argparse.ArgumentParser`", "`prog`_, `description`_, `formatter_class`_", "``parser = argparse.ArgumentParser(prog='PROG', description='DESC', formatter_class=argparse.RawDescriptionHelpFormatter)``"
":func:`ArgumentParser.add_argument`", "`name or flags`_, `action`_, `default`_, `type`_, `required`_, `help`_", "``parser.add_argument('-v', '--verbose', action='store_true', help='Show various debugging information')``"
The :class:`argparse.ArgumentParser` creates a new :class:`ArgumentParser` object. Commonly used arguments include `prog`_, `description`_, and `formatter_class`_. For example, the user can create an instance of :class:`ArgumentParser` through the following::

>>> parser = argparse.ArgumentParser(prog='PROG', description='DESC',
... formatter_class=argparse.RawDescriptionHelpFormatter)

The :func:`ArgumentParser.add_argument` is a function that is used to define how a single command-line argument should be parsed. Commonly used arguments include `name or flags`_, `action`_, `default`_, `type`_, `required`_, and `help`_. An example of the function :func:`ArgumentParser.add_argument` is as follows::

>>> parser.add_argument('-v', '--verbose', action='store_true',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency please also use hanging indentation here, with a single argument per line.

... help='Show various debugging information')


Basic Usage of :func:`add_argument`
Expand Down Expand Up @@ -744,7 +750,7 @@ The add_argument() method
The following sections describe how each of these are used.


.. _name or flags:
.. ref:`name or flags`

name or flags
^^^^^^^^^^^^^
Expand Down
0