Loading .travis.yml +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ script: fi deploy: provider: pypi distributions: 'release sdist bdist_wheel' distributions: 'sdist bdist_wheel' on: tags: true python: 3.6 Loading doc/changelog.rst +8 −0 Original line number Diff line number Diff line Changelog ========= Version 0.1.5 ------------- Released on May 15, 2018. - New ``:groups:`` option to render argument groups. [by Lukas Atkinson] Version 0.1.4 ------------- Loading doc/cli_with_groups.py 0 → 100644 +18 −0 Original line number Diff line number Diff line import argparse parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', help='An integer for the accumulator.') calculator_opts = parser.add_argument_group('Calculator Options') calculator_opts.add_argument( '-i', '--identity', type=int, default=0, help='the default result for no arguments ' '(default: 0)') calculator_opts.add_argument( '--sum', dest='accumulate', action='store_const', const=sum, default=max, help='Sum the integers (default: find the max).') if __name__ == '__main__': args = parser.parse_args() print(args.accumulate(args.integers)) doc/index.rst +33 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ That's it. It will be rendered as: :prog: cli.py If there are subcommands (subparsers), they are rendered to subsections. For example, givem the following Python CLI program (say it's For example, given the following Python CLI program (say it's :file:`subcmds.py`): .. include:: subcmds.py Loading @@ -78,6 +78,25 @@ The above reStructuredText will render: .. autoprogram:: subcmds:parser :prog: subcmds.py If there are argument groups, they can optionally be rendered as subsections, just like subcommands. For example: .. include:: cli_with_groups.py :code: .. code-block:: rst .. autoprogram:: cli_with_groups:parser :prog: cli_with_groups.py :groups: The above reStructuredText Text will render: .. autoprogram:: cli_with_groups:parser :prog: cli_with_groups.py :groups: .. rst:directive:: .. autoprogram:: module:parser It takes an import name of the parser object. For example, if ``xyz`` Loading Loading @@ -108,23 +127,34 @@ The above reStructuredText will render: Additional Options for :rst:dir:`.. autoprogram::` -------------------------------------------------- .. versionadded:: 0.1.3 ``:groups:`` Render argument groups as subsections. .. versionadded:: 0.1.5 ``:maxdepth: ##`` Only show subcommands to a depth of ``##``. .. versionadded:: 0.1.3 ``:no_usage_codeblock:`` Don't put the usage text in a :rst:dir:`.. codeblock:: console` directive. .. versionadded:: 0.1.3 ``:start_command: subcommand`` Render document for the given subcommand. ``subcommand`` can be a space separated list to render a sub-sub-...-command. .. versionadded:: 0.1.3 ``:strip_usage:`` Removes all but the last word in the usage string before the first option, replaces it with '...', and removes an amount of whitespace to realign subsequent lines. .. versionadded:: 0.1.3 Author and license ------------------ Loading setup.cfg +0 −7 Original line number Diff line number Diff line [egg_info] tag_build = dev tag_date = true [bdist_wheel] universal = 1 [aliases] release = egg_info -RDb '' Loading
.travis.yml +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ script: fi deploy: provider: pypi distributions: 'release sdist bdist_wheel' distributions: 'sdist bdist_wheel' on: tags: true python: 3.6 Loading
doc/changelog.rst +8 −0 Original line number Diff line number Diff line Changelog ========= Version 0.1.5 ------------- Released on May 15, 2018. - New ``:groups:`` option to render argument groups. [by Lukas Atkinson] Version 0.1.4 ------------- Loading
doc/cli_with_groups.py 0 → 100644 +18 −0 Original line number Diff line number Diff line import argparse parser = argparse.ArgumentParser(description='Process some integers.') parser.add_argument('integers', metavar='N', type=int, nargs='+', help='An integer for the accumulator.') calculator_opts = parser.add_argument_group('Calculator Options') calculator_opts.add_argument( '-i', '--identity', type=int, default=0, help='the default result for no arguments ' '(default: 0)') calculator_opts.add_argument( '--sum', dest='accumulate', action='store_const', const=sum, default=max, help='Sum the integers (default: find the max).') if __name__ == '__main__': args = parser.parse_args() print(args.accumulate(args.integers))
doc/index.rst +33 −3 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ That's it. It will be rendered as: :prog: cli.py If there are subcommands (subparsers), they are rendered to subsections. For example, givem the following Python CLI program (say it's For example, given the following Python CLI program (say it's :file:`subcmds.py`): .. include:: subcmds.py Loading @@ -78,6 +78,25 @@ The above reStructuredText will render: .. autoprogram:: subcmds:parser :prog: subcmds.py If there are argument groups, they can optionally be rendered as subsections, just like subcommands. For example: .. include:: cli_with_groups.py :code: .. code-block:: rst .. autoprogram:: cli_with_groups:parser :prog: cli_with_groups.py :groups: The above reStructuredText Text will render: .. autoprogram:: cli_with_groups:parser :prog: cli_with_groups.py :groups: .. rst:directive:: .. autoprogram:: module:parser It takes an import name of the parser object. For example, if ``xyz`` Loading Loading @@ -108,23 +127,34 @@ The above reStructuredText will render: Additional Options for :rst:dir:`.. autoprogram::` -------------------------------------------------- .. versionadded:: 0.1.3 ``:groups:`` Render argument groups as subsections. .. versionadded:: 0.1.5 ``:maxdepth: ##`` Only show subcommands to a depth of ``##``. .. versionadded:: 0.1.3 ``:no_usage_codeblock:`` Don't put the usage text in a :rst:dir:`.. codeblock:: console` directive. .. versionadded:: 0.1.3 ``:start_command: subcommand`` Render document for the given subcommand. ``subcommand`` can be a space separated list to render a sub-sub-...-command. .. versionadded:: 0.1.3 ``:strip_usage:`` Removes all but the last word in the usage string before the first option, replaces it with '...', and removes an amount of whitespace to realign subsequent lines. .. versionadded:: 0.1.3 Author and license ------------------ Loading
setup.cfg +0 −7 Original line number Diff line number Diff line [egg_info] tag_build = dev tag_date = true [bdist_wheel] universal = 1 [aliases] release = egg_info -RDb ''