comparison 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
comparison
equal deleted inserted replaced
137:cc0765aae484 138:3e89d1c4f721
20 ## 20 ##
21 21
22 22
23 import argparse 23 import argparse
24 import clang.cindex 24 import clang.cindex
25 import json
25 import os 26 import os
26 import pprint 27 import pprint
27 import pystache 28 import pystache
28 import sys 29 import sys
29 30
386 })) 387 }))
387 388
388 enumerations[name] = { 389 enumerations[name] = {
389 'name' : name, 390 'name' : name,
390 'path' : path, 391 'path' : path,
392 'values' : values,
391 } 393 }
392 394
393 elif node.kind == clang.cindex.CursorKind.FUNCTION_DECL: 395 elif node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
394 if node.spelling.startswith('OrthancPlugin'): 396 if node.spelling.startswith('OrthancPlugin'):
395 #if node.spelling != 'OrthancPluginWorklistGetDicomQuery': 397 #if node.spelling != 'OrthancPluginWorklistGetDicomQuery':
553 h.write(renderer.render(f.read(), { 555 h.write(renderer.render(f.read(), {
554 'classes' : sortedClasses, 556 'classes' : sortedClasses,
555 })) 557 }))
556 558
557 559
560 with open(os.path.join(TARGET, 'CodeModel.json'), 'w') as f:
561 f.write(json.dumps({
562 'global_functions' : globalFunctions,
563 'classes' : sortedClasses,
564 'enumerations' : sortedEnumerations,
565 'global_functions' : globalFunctions,
566 }, ensure_ascii = True, indent = 4, sort_keys = True))
567
568
558 print('') 569 print('')
559 print('Total functions in the SDK: %d' % countAllFunctions) 570 print('Total functions in the SDK: %d' % countAllFunctions)
560 print('Total supported functions: %d' % countSupportedFunctions) 571 print('Total supported functions: %d' % countSupportedFunctions)
561 print('Coverage: %.0f%%' % (float(countSupportedFunctions) / 572 print('Coverage: %.0f%%' % (float(countSupportedFunctions) /
562 float(countAllFunctions) * 100.0)) 573 float(countAllFunctions) * 100.0))