Skip to content
This repository has been archived by the owner on Feb 10, 2023. It is now read-only.

Commit

Permalink
Show the command line arguments in the documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mineo committed Apr 16, 2016
1 parent 567265f commit 9b01d8f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 16 deletions.
33 changes: 19 additions & 14 deletions abzer/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@ def collect_files(dir):
yield join(dir, dirpath, filename)


def make_argparser():
parser = argparse.ArgumentParser(prog="abzer",
formatter_class=argparse.ArgumentDefaultsHelpFormatter) # noqa
parser.add_argument("filenames", metavar="FILENAME", nargs="+")
parser.add_argument("-c", "--config",
help="The path to the config file.",
default=const.DEFAULT_CONFIG_PATH)
parser.add_argument("-p", "--processes",
help="The number of processes to use for analyzing files.", # noqa
default=cpu_count(),
type=int)
parser.add_argument("-v", "--verbose",
help="Be more verbose.",
action="store_true",
default=False)
return parser


def read_config(filename):
"""
:param filename:
Expand All @@ -39,20 +57,7 @@ def safety_check(config):


def main():
parser = argparse.ArgumentParser(prog="abzer",
formatter_class=argparse.ArgumentDefaultsHelpFormatter) # noqa
parser.add_argument("filenames", metavar="FILENAME", nargs="+")
parser.add_argument("-c", "--config",
help="The path to the config file.",
default=const.DEFAULT_CONFIG_PATH)
parser.add_argument("-p", "--processes",
help="The number of processes to use for analyzing files.", # noqa
default=cpu_count(),
type=int)
parser.add_argument("-v", "--verbose",
help="Be more verbose.",
action="store_true",
default=False)
parser = make_argparser()
args = parser.parse_args()

if args.verbose:
Expand Down
3 changes: 2 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage',
'sphinx.ext.viewcode', 'sphinx.ext.intersphinx']
'sphinx.ext.viewcode', 'sphinx.ext.intersphinx',
'sphinxcontrib.autoprogram']
sys.path.insert(0, os.path.abspath("../../"))
from abzer import __version__
autodoc_default_flags = ["members", "undoc-members", "show-inheritance"]
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Contents:
:maxdepth: 2

setup
usage

API:

Expand Down
8 changes: 8 additions & 0 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Usage
=====

Command line options
--------------------

.. autoprogram:: abzer.__main__:make_argparser()
:prog: abzer
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
use_scm_version={"write_to": "abzer/version.py"},
install_requires=["aiohttp"],
extras_require={
'docs': ['sphinx']},
'docs': ['sphinx', 'sphinxcontrib-autoprogram']},
entry_points={
'console_scripts': ['abzer=abzer.__main__:main']
}
Expand Down

0 comments on commit 9b01d8f

Please sign in to comment.