9 fd.write(
"".
join(comment))
14 m = re.match(
r" */", comment[0])
17 raise Exception(
"{}: Not a comment ? '{}'".
format(path,comment[first_param]))
19 line_prefix =
" " * len(m.group(0)) +
"*"
20 empty_line = line_prefix +
"\n"
24 for comment_line
in range(1,first_param):
25 line = comment[comment_line]
26 m = re.match(
" *\*(.*)", line)
28 raise Exception(
"{}:{}: Not a comment line ? ".
format(path, n_line - len(comment) + comment_line + 1))
29 fd.write(line_prefix+ m.group(1)+
"\n")
32 for param
in range(first_param, last_param):
33 m = re.match(
r"[^@]+(@param\[[^\]]+\]) +(\S+) +(.+)", comment[param])
36 params.append( (
" "+m.group(1), m.group(2), m.group(3)) )
40 m = re.match(
" *\* +(.*)", comment[param])
42 raise Exception(
"{}:{}: Not a comment line ? ".
format(path, n_line - len(comment) + param + 1))
44 params.append( (
"",
"", m.group(1)) )
50 for l
in range(len(max_len)):
51 max_len[l] = max(max_len[l], len(p[l]))
54 m = re.match(
r" *\* *$", comment[first_param - 1])
62 fd.write(
"{}{}{} {}{} {}\n".
format( line_prefix,
63 p[0],
" " * (max_len[0] - len(p[0])),
64 p[1],
" " * (max_len[1] - len(p[1])),
68 if last_param < len(comment) - 1:
69 if re.match(
r" *\* *@\w+", comment[last_param]):
74 for comment_line
in range(last_param,len(comment)):
75 line = comment[comment_line]
76 m = re.match(
" *\*(.*)", line)
78 raise Exception(
"{}:{}: Not a comment line ? ".
format(path, n_line - len(comment) + comment_line + 1))
79 fd.write(line_prefix+ m.group(1)+
"\n")
81 if __name__ ==
"__main__":
84 if len(sys.argv) == 2
and sys.argv[1] ==
'--all':
87 for top_level
in [
"./arm_compute",
"./src",
"./examples",
"./tests",
"./utils",
"./framework",
"./support"]:
88 for root, _, files
in os.walk(top_level):
89 paths.extend([os.path.join(root, f)
for f
in files])
94 if (path[-3:]
not in (
"cpp",
"inl")
and
95 path[-2:]
not in (
"cl")
and
96 path[-2:]
not in (
"cs")
and
97 path[-1]
not in (
"h")):
100 print(
"[{}] {}".
format(n_file, path))
104 with open(path,
'r+', encoding=
"utf-8")
as fd:
110 lines = fd.readlines()
119 if re.search(
r"/\*", line):
123 raise Exception(
"{}:{}: Already in a comment!".
format(path,n_line))
128 elif len(comment) > 0:
141 if re.search(
r"@param\[[^\]]+\] +\S+ +\S", line):
145 first_param = len(comment) - 1
147 last_param = len(comment)
150 if re.search(
r"\*/", line):
151 if re.search(
'"[^"]*\*/[^"]*"', line):
158 raise Exception(
"{}:{}: Was not in a comment! ".
format(path, n_line))