more documentation
authorTomas Musil <tomik.musil@gmail.com>
Sat, 12 Oct 2013 23:03:07 +0000 (01:03 +0200)
committerTomas Musil <tomik.musil@gmail.com>
Sat, 12 Oct 2013 23:03:07 +0000 (01:03 +0200)
doc/conf.py
doc/index.rst
doc/usage.rst [new file with mode: 0644]
imago_pack/imago.py

index 7f80be6..d859018 100644 (file)
@@ -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.
index 78eb278..7c0ed3b 100644 (file)
@@ -12,6 +12,7 @@ Contents:
    :maxdepth: 2
 
     Introduction <intro>
+    Usage <usage>
     Modules <modules>
 
 
diff --git a/doc/usage.rst b/doc/usage.rst
new file mode 100644 (file)
index 0000000..2d14a61
--- /dev/null
@@ -0,0 +1,9 @@
+Usage
+=====
+
+.. argparse::
+   :module: imago
+   :func: argument_parser
+   :prog: imago
+
+.. TODO get rid of the Sub-commands header
index 33e7c69..c0e6202 100755 (executable)
@@ -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)