[ARVADOS] updated: d8c504bddb3c5940fc6955ae7107f06736f85022

git at public.curoverse.com git at public.curoverse.com
Tue Dec 31 13:24:12 EST 2013


Summary of changes:
 doc/gen_api_method_docs.py |  102 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 102 insertions(+), 0 deletions(-)
 create mode 100755 doc/gen_api_method_docs.py

       via  d8c504bddb3c5940fc6955ae7107f06736f85022 (commit)
      from  993f62a209b5f9ec12779aed46d25e18e48cbbba (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit d8c504bddb3c5940fc6955ae7107f06736f85022
Author: Tim Pierce <twp at clinicalfuture.com>
Date:   Tue Dec 31 13:23:24 2013 -0500

    Added gen_api_method_docs.py used to generate API documentation files.

diff --git a/doc/gen_api_method_docs.py b/doc/gen_api_method_docs.py
new file mode 100755
index 0000000..ddafeea
--- /dev/null
+++ b/doc/gen_api_method_docs.py
@@ -0,0 +1,102 @@
+#! /usr/bin/env python
+
+# gen_api_method_docs.py
+#
+# Generate docs for Arvados methods.
+#
+# This script will retrieve the discovery document at
+# https://localhost:9900/discovery/v1/apis/arvados/v1/rest
+# and will generate Textile documentation files in the current
+# directory.
+
+import requests
+import re
+import os
+import pprint
+
+r = requests.get('https://localhost:9900/discovery/v1/apis/arvados/v1/rest',
+                 verify=False)
+if r.status_code != 200:
+    raise Exception('Bad status code %d: %s' % (r.status_code, r.text))
+
+if 'application/json' not in r.headers.get('content-type', ''):
+    raise Exception('Unexpected content type: %s: %s' %
+                    (r.headers.get('content-type', ''), r.text))
+
+api = r.json
+
+resource_num = 0
+for resource in sorted(api[u'resources']):
+    resource_num = resource_num + 1
+    out_fname = resource + '.textile'
+    if os.path.exists(out_fname):
+        print "PATH EXISTS ", out_fname
+        next
+    outf = open(out_fname, 'w')
+    outf.write(
+"""---
+layout: default
+navsection: api
+navmenu: API Methods
+title: "{resource}"
+navorder: {resource_num}
+---
+
+h1. {resource}
+
+Required arguments are displayed in %{{background:#ccffcc}}green%.
+
+""".format(resource_num=resource_num, resource=resource))
+
+    methods = api['resources'][resource]['methods']
+    for method in sorted(methods.keys()):
+        methodinfo = methods[method]
+        outf.write(
+"""
+h2. {method}
+
+{description}
+
+Arguments:
+
+table(table table-bordered table-condensed).
+|_. Argument |_. Type |_. Description |_. Location |_. Example |
+""".format(
+    method=method, description=methodinfo['description']))
+
+        required = []
+        notrequired = []
+        for param, paraminfo in methodinfo['parameters'].iteritems():
+            paraminfo.setdefault(u'description', '')
+            paraminfo.setdefault(u'location', '')
+            limit = ''
+            if paraminfo.get('minimum', '') or paraminfo.get('maximum', ''):
+                limit = "range {0}-{1}".format(
+                    paraminfo.get('minimum', ''),
+                    paraminfo.get('maximum', 'unlimited'))
+            if paraminfo.get('default', ''):
+                if limit:
+                    limit = limit + '; '
+                limit = limit + 'default %d' % paraminfo['default']
+            if limit:
+                paraminfo['type'] = '{0} ({1})'.format(
+                    paraminfo['type'], limit)
+
+            row = "|{param}|{type}|{description}|{location}||\n".format(
+                param=param, **paraminfo)
+            if paraminfo.get('required', False):
+                required.append(row)
+            else:
+                notrequired.append(row)
+
+        for row in sorted(required):
+            outf.write("{background:#ccffcc}." + row)
+        for row in sorted(notrequired):
+            outf.write(row)
+
+        # pprint.pprint(methodinfo)
+
+    outf.close()
+    print "wrote ", out_fname
+
+

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list