MCPcopy
hub / github.com/KhronosGroup/Vulkan-Docs / generate_map

Function generate_map

scripts/map_html_anchors.py:115–135  ·  view source on GitHub ↗

Encode the ID map into the specified scripttype ('python' or 'javascript') in the specified file.

(id_map, filename, scripttype)

Source from the content-addressed store, hash-verified

113 id_map[id] = [ chapter_id, id_title ]
114
115def generate_map(id_map, filename, scripttype):
116 """Encode the ID map into the specified scripttype ('python' or
117 'javascript') in the specified file."""
118
119 fp = open(filename, 'w')
120
121 # Python and JS are extremely similar when the output is just a
122 # dictionary of lists of strings.
123
124 if scripttype == 'javascript':
125 print('exports.xrefMap = {', file=fp)
126 else:
127 print('xrefMap = {', file=fp)
128
129 # Sort keys so the can be compared between runs
130 for id in sorted(id_map):
131 print(f" '{id}' : [ '{id_map[id][0]}', '{id_map[id][1]}' ],", file=fp)
132
133 print('}', file=fp)
134
135 fp.close()
136
137if __name__ == '__main__':
138 parser = argparse.ArgumentParser()

Callers 1

Calls 1

closeMethod · 0.45

Tested by

no test coverage detected