Add a presubmit that functions names are snake_case

R=lalitm@google.com

Change-Id: Ic55ba07d4307cd97d3d854f79b41c2927b81ce34
diff --git a/tools/gen_stdlib_docs_json.py b/tools/gen_stdlib_docs_json.py
index dcb4023..ee99675 100755
--- a/tools/gen_stdlib_docs_json.py
+++ b/tools/gen_stdlib_docs_json.py
@@ -23,7 +23,7 @@
 ROOT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
 sys.path.append(os.path.join(ROOT_DIR))
 
-from python.generators.stdlib_docs.parse import parse_file_to_dict
+from python.generators.stdlib_docs.parse import parse_file
 
 
 def main():
@@ -70,16 +70,35 @@
     module_name = path.split("/")[0]
     import_key = path.split(".sql")[0].replace("/", ".")
 
-    docs = parse_file_to_dict(path, sql)
-    if isinstance(docs, list):
-      for d in docs:
-        print(d)
+    docs = parse_file(path, sql)
+    if len(docs.errors) > 0:
+      for e in docs.errors:
+        print(e)
       return 1
 
-    assert isinstance(docs, dict)
-    if not any(docs.values()):
-      continue
-    file_dict = {'import_key': import_key, **docs}
+    file_dict = {
+        'import_key':
+            import_key,
+        'imports': [{
+            'name': table.name,
+            'desc': table.desc,
+            'type': table.type,
+            'cols': table.cols,
+        } for table in docs.table_views],
+        'functions': [{
+            'name': function.name,
+            'desc': function.desc,
+            'args': function.args,
+            'return_type': function.return_type,
+            'return_desc': function.return_desc,
+        } for function in docs.functions],
+        'view_functions': [{
+            'name': function.name,
+            'desc': function.desc,
+            'args': function.args,
+            'cols': function.cols,
+        } for function in docs.table_functions],
+    }
     modules[module_name].append(file_dict)
 
   with open(args.json_out, 'w+') as f: