MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / parseFiles

Function parseFiles

site/source/get_api_items.py:28–70  ·  view source on GitHub ↗

Parse api-reference files to extract the code items.

()

Source from the content-addressed store, hash-verified

26
27
28def parseFiles():
29 """Parse api-reference files to extract the code items."""
30
31 def addapiitems(matchobj):
32 # print 'matcobj0: %s' % matchobj.group(0)
33 # print 'matcobj1: %s' % matchobj.group(1)
34 # print 'matcobj2: %s' % matchobj.group(2)
35 # print 'matcobj3: %s' % matchobj.group(3)
36 # print 'matcobj4: %s' % matchobj.group(4)
37
38 lang = matchobj.group(2)
39 data_type = matchobj.group(3)
40 if data_type == 'function':
41 data_type = 'func'
42 api_item = matchobj.group(4)
43 api_item = api_item.strip()
44 api_item = api_item.split('(')[0]
45 try:
46 api_item = api_item.split(' ')[1]
47 except IndexError:
48 pass
49
50 # print lang
51 # print data_type
52 # print api_item
53
54 api_reference_items[api_item] = ':%s:%s:`%s`' % (lang, data_type, api_item)
55 # Add additional index for functions declared as func() rather than just func
56 if data_type == 'func':
57 api_item_index = api_item + '()'
58 api_reference_items[api_item_index] = ':%s:%s:`%s`' % (lang, data_type, api_item)
59
60 # print api_reference_items[api_item]
61
62 for file in os.listdir(api_reference_directory):
63 if file.endswith(".rst"):
64 filepath = api_reference_directory + file
65 print(file)
66 # open file
67 with open(filepath, encoding='utf-8') as infile:
68 for line in infile:
69 # parse line for API items
70 re.sub(r'^\.\.\s+((\w+)\:(\w+)\:\:(.*))', addapiitems, line)
71
72
73def exportItems():

Callers 1

mainFunction · 0.85

Calls 2

printFunction · 0.50
openFunction · 0.50

Tested by

no test coverage detected