diff CodeAnalysis/ParseOrthancSDK.py @ 138:3e89d1c4f721

export the code model as json
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 13 Sep 2023 17:51:00 +0200
parents c55b0583084b
children b6835b7a7c0a
line wrap: on
line diff
--- a/CodeAnalysis/ParseOrthancSDK.py	Tue Sep 05 13:32:32 2023 +0200
+++ b/CodeAnalysis/ParseOrthancSDK.py	Wed Sep 13 17:51:00 2023 +0200
@@ -22,6 +22,7 @@
 
 import argparse
 import clang.cindex
+import json
 import os
 import pprint
 import pystache
@@ -388,6 +389,7 @@
             enumerations[name] = {
                 'name' : name,
                 'path' : path,
+                'values' : values,
             }
 
     elif node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
@@ -555,6 +557,15 @@
         }))
 
 
+with open(os.path.join(TARGET, 'CodeModel.json'), 'w') as f:
+    f.write(json.dumps({
+        'global_functions' : globalFunctions,
+        'classes' : sortedClasses,
+        'enumerations' : sortedEnumerations,
+        'global_functions' : globalFunctions,
+    }, ensure_ascii = True, indent = 4, sort_keys = True))
+
+
 print('')
 print('Total functions in the SDK: %d' % countAllFunctions)
 print('Total supported functions: %d' % countSupportedFunctions)