MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / minifier

Function minifier

api-docs/cppdocs/build_min_docs.py:84–128  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82
83
84def minifier():
85
86 # Typically, doxygen's navbar will lazy load the data in all of these variables.
87 # While this has miniscule performance benefits, it generates thousands of js files.
88 # Here, we take all js variables that the navbar will ever be able to load, and
89 # add them to the top of the navbar.js file itself.
90
91 navtree_built_data = ""
92 for mod in load_items_in_file("html/topics.js"):
93 navtree_built_data += mod + "\n"
94 for mod in load_items_in_file("html/namespaces.js"):
95 navtree_built_data += mod + "\n"
96 for mod in load_items_in_file("html/annotated.js"):
97 navtree_built_data += mod + "\n"
98
99 # The navtree indices also need to be loaded in since we're modifying how navbar.js::getScript works.
100 # This also saves another ~60 files.
101 for nav_tree_index_file in os.listdir("html"):
102 if 'navtreeindex' in nav_tree_index_file:
103 with open("html/" + nav_tree_index_file, "r") as fp:
104 navtree_built_data += fp.read() + "\n"
105 deletion_queue.append("html/" + nav_tree_index_file)
106
107 while "\n\n" in navtree_built_data:
108 navtree_built_data = navtree_built_data.replace("\n\n", "\n")
109
110 navtree_built_data = navtree_built_data.replace("\n", "")
111
112 fp = open("html/navtree.js", "r")
113 navtree_orig = fp.read()
114 fp.close()
115
116 # getScript(scriptName,func,show) here originally loads the js file and calls func once that is complete
117 # Here, we just want to skip the whole process and immediately call the callback.
118 nav_tree_fixed_get_script = "function getScript(scriptName,func,show) { func(); }"
119
120 navtree_before_get_script = navtree_orig.split("const getScript = function(scriptName,func) {")[0]
121 navtree_after_get_script = navtree_orig.split("const getScript = function(scriptName,func) {")[1].split('}', 1)[1]
122
123 nav_tree_fixed = navtree_before_get_script + nav_tree_fixed_get_script + navtree_after_get_script
124 navtree = navtree_built_data + "\n" + nav_tree_fixed
125
126 fp = open("html/navtree.js", "w")
127 fp.write(navtree)
128 fp.close()
129
130
131def build_doxygen(args):

Callers 1

mainFunction · 0.85

Calls 7

load_items_in_fileFunction · 0.85
readMethod · 0.45
appendMethod · 0.45
replaceMethod · 0.45
closeMethod · 0.45
splitMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected