forked from ecrc/stars-h
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_filenames_in_docs.py
36 lines (30 loc) · 1.14 KB
/
update_filenames_in_docs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# This script looks into every .c file in src/ directory every .h file in
# include/ directory and updates filename in doxygen comment with @file
from __future__ import print_function
from glob import glob
src_files = glob("../src/*.c")
src_files.extend(glob("../src/*/*.c"))
src_files.extend(glob("../src/*/*/*.c"))
src_files.extend(glob("../src/*/*/*/*.c"))
src_files.extend(glob("../testing/*.c"))
src_files.extend(glob("../testing/*/*.c"))
src_files.extend(glob("../examples/*.c"))
src_files.extend(glob("../examples/*/*.c"))
h_files = glob("../include/*.h")
all_files = src_files+h_files
for fname in all_files:
with open(fname, "r+") as fd:
lines = fd.readlines()
fd.seek(0)
fd.truncate()
for line in lines:
ind = line.find(r"@file")
if ind != -1:
newline = line[:ind+6]+fname[3:]+"\n"
if newline != line:
print("Warning: wrong file name was fixed in {}".
format(fname))
line = newline
fd.write(line)
print("File {} was succesfully processed".format(fname))