Skip to content

Commit 2d25db6

Browse files
committed
adds logic for replace doxygen-comment to brief-comment in deploy script
1 parent 0b49b6d commit 2d25db6

1 file changed

Lines changed: 14 additions & 13 deletions

File tree

compile.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -70,42 +70,43 @@ def parse_sctipt_info(content):
7070
# поиск блока doxygen комментариев, начинающихся с "/*!"
7171
match = re.search(r'/\*!(.*)\*/', content, flags = re.MULTILINE | re.DOTALL)
7272
if not match:
73-
return info
74-
comment_begin, comment_end = match.start(1), match.end(1)
75-
other_info_begin = comment_begin
73+
return info, 0, 0
74+
start, end = match.start(1), match.end(1)
75+
pos = start
76+
other_info_begin = pos
7677

7778
# поиск названия функции\процедуры
7879
type_map = {'fn' : ('procedure', 'parameter')
7980
, 'tb' : ('table', 'column')
8081
, 'tg' : ('trigger', None)
8182
, 'sq' : ('sequence', None)}
8283

83-
match = re.search(r'\\(' + '|'.join(type_map.keys()) + r')\s+(\w+)', content[comment_begin:comment_end])
84+
match = re.search(r'\\(' + '|'.join(type_map.keys()) + r')\s+(\w+)', content[pos:end])
8485
if match:
8586
info['name'] = match.group(2)
8687
info['type'], info['param_type'] = type_map[match.group(1)]
87-
other_info_begin = max(other_info_begin, comment_begin + match.end() + 1)
88+
other_info_begin = max(other_info_begin, pos + match.end() + 1)
8889

8990
# поиск короткого описания
9091
info['brief'] = None
9192
pattern = re.compile(r'\\brief\s+(.+?)(?:\\param|(?:^\s*$))', re.S + re.M)
92-
match = re.search(pattern, content[comment_begin:comment_end])
93+
match = re.search(pattern, content[pos:end])
9394
if match:
9495
info['brief'] = match.group(1).strip()
95-
other_info_begin = max(other_info_begin, comment_begin + match.end() + 1)
96+
other_info_begin = max(other_info_begin, pos + match.end() + 1)
9697

9798
info['inputs'] = []
9899
info['outputs'] = []
99100
# поиск описания параметров
100101
if info['param_type']:
101102
pattern = re.compile(r'\\param(?:\[(?P<direction>in|out)\])?\s+(?P<parameter>\w+)\s+(?P<comment>.*)')
102103

103-
for match in pattern.finditer(content[comment_begin:comment_end]):
104+
for match in pattern.finditer(content[pos:end]):
104105
info['outputs' if match.group('direction') == 'out' else 'inputs'].append(match.groupdict())
105-
other_info_begin = max(other_info_begin, comment_begin + match.end() + 1)
106+
other_info_begin = max(other_info_begin, pos + match.end() + 1)
106107

107-
info['description'] = content[other_info_begin:comment_end].strip()
108-
return info
108+
info['description'] = content[other_info_begin:end].strip()
109+
return info, start, end
109110

110111

111112
def add_comments_block(content, info):
@@ -135,8 +136,8 @@ def prepareFileContent(fname, encoding, params):
135136
print('processing file: {}'.format(fname))
136137

137138
content = f.read()
138-
script_info = parse_sctipt_info(content)
139-
139+
script_info, start, end = parse_sctipt_info(content)
140+
content = content[:start] + (script_info['brief'] or '') + content[end:]
140141
content = add_git_info(content, get_git_info(fname))
141142
content = add_comments_block(content, script_info)
142143
try:

0 commit comments

Comments
 (0)