From 6adc93a079b4b252b2047c0d59f51e5973a9c469 Mon Sep 17 00:00:00 2001 From: Tomas Musil Date: Sun, 13 Oct 2013 01:03:07 +0200 Subject: [PATCH 1/1] more documentation --- doc/conf.py | 1 + doc/index.rst | 1 + doc/usage.rst | 9 +++++++++ imago_pack/imago.py | 17 +++++++++++------ 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 doc/usage.rst diff --git a/doc/conf.py b/doc/conf.py index 7f80be6..d859018 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -34,6 +34,7 @@ extensions = [ 'sphinx.ext.coverage', 'sphinx.ext.pngmath', 'sphinx.ext.viewcode', + 'sphinxarg.ext', ] # Add any paths that contain templates here, relative to this directory. diff --git a/doc/index.rst b/doc/index.rst index 78eb278..7c0ed3b 100644 --- a/doc/index.rst +++ b/doc/index.rst @@ -12,6 +12,7 @@ Contents: :maxdepth: 2 Introduction + Usage Modules diff --git a/doc/usage.rst b/doc/usage.rst new file mode 100644 index 0000000..2d14a61 --- /dev/null +++ b/doc/usage.rst @@ -0,0 +1,9 @@ +Usage +===== + +.. argparse:: + :module: imago + :func: argument_parser + :prog: imago + +.. TODO get rid of the Sub-commands header diff --git a/imago_pack/imago.py b/imago_pack/imago.py index 33e7c69..c0e6202 100755 --- a/imago_pack/imago.py +++ b/imago_pack/imago.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -"""Go image recognition""" +"""Go image recognition.""" import sys import os @@ -19,9 +19,7 @@ import manual import intrsc import gridf -def main(): - """Main function of the program.""" - +def argument_parser(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('files', metavar='file', nargs='+', help="image to analyse") @@ -39,6 +37,13 @@ def main(): help="use cached lines") parser.add_argument('-v', '--verbose', dest='verbose', action='store_true', help="report progress") + return parser + + +def main(): + """Main function of the program.""" + + parser = argument_parser() args = parser.parse_args() show_all = args.show_all @@ -133,6 +138,6 @@ class Imsave(): if __name__ == '__main__': try: sys.exit(main()) - except KeyboardInterrupt: + except KeyboardInterrupt: #TODO does this work? print "Interrupted." - sys.exit() + sys.exit(1) -- 2.4.2