MCPcopy Create free account
hub / github.com/AMReX-Astro/Castro / process_cpp_file

Function process_cpp_file

Docs/add_doxy_headers.py:206–247  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

204
205
206def process_cpp_file(filename):
207
208 output_data = ""
209
210 # find comments in lines above
211 re_comments = re.compile(
212 r"[ \t]*(\/\/[ \t]*[\S ^\n]*?)\n^[ \t]*[^\/]", flags=re.MULTILINE)
213
214 re_prototype = re.compile(
215 r"^\w*\n^\w[~\w:*& ]+\([\w\: \,&\n\t_=<>.]*\)\n?[\s\S]*?\n?{", flags=re.MULTILINE)
216
217 with open(filename) as input_file:
218 data = input_file.read()
219
220 last_index = 0
221
222 for m in re.finditer(re_prototype, data):
223
224 comments = None
225
226 for comments in re.finditer(re_comments,
227 data[last_index:m.start() + 1]):
228 pass
229
230 if comments and (m.start() - comments.end() - last_index) < 3:
231 output_data += data[last_index:last_index + comments.start()]
232 method_header = make_method_doxycomment(comments.group(1))
233 last_index = m.start()
234
235 else:
236 output_data += data[last_index:m.start()]
237 method_header = make_method_doxycomment("")
238 last_index = m.start()
239
240 output_data += method_header
241
242 output_data += data[last_index:]
243
244 output_filename = filename + ".doxygen"
245
246 with open(output_filename, 'w+') as output_file:
247 output_file.write(output_data)
248
249
250if __name__ == "__main__":

Callers 1

Calls 1

make_method_doxycommentFunction · 0.85

Tested by

no test coverage detected