|
1 | 1 | #!/usr/bin/python3
|
2 |
| -# |
3 |
| -# srcxray - source code X-ray |
4 |
| -# |
5 |
| -# Analyzes interconnections between functions and structures in source code. |
6 |
| -# |
| 2 | + |
| 3 | +""" |
| 4 | +
|
| 5 | + srcxray - source code X-ray |
| 6 | +
|
| 7 | +Analyzes interconnections between functions and structures in source code. |
| 8 | +""" |
7 | 9 | # Uses doxygen, git grep --show-functionm and cscope to
|
8 | 10 | # reveal references between identifiers.
|
9 | 11 | #
|
|
34 | 36 | import difflib
|
35 | 37 | import glob
|
36 | 38 | from pathlib import *
|
37 |
| -import pygraphviz # python3-pygraphviz |
| 39 | +import pygraphviz # sudo dnf install -yq python3-pygraphviz |
38 | 40 | import graphviz # python3-graphviz
|
39 | 41 | import unittest
|
40 | 42 | import types
|
@@ -171,10 +173,14 @@ def func_referrers_git_grep(name):
|
171 | 173 | # Obsoleted by doxygen_xml.
|
172 | 174 | res = list()
|
173 | 175 | r = None
|
174 |
| - for line in popen(r'git grep --threads 1 --no-index --word-regexp ' |
175 |
| - r'--show-function --line-number ' |
| 176 | + # --threads 1--no-index r'**.\[hc\] **.cpp **.cc **.hh' |
| 177 | + for line in popen(r'git grep ' |
| 178 | + r'--show-function ' |
| 179 | + r'--line-number ' |
176 | 180 | r'"^\s.*\b%s" '
|
177 |
| - r'**.\[hc\] **.cpp **.cc **.hh || true' % (name)): |
| 181 | + r'$(git grep --word-regexp --files-with-matches ' |
| 182 | + r'"%s" )' |
| 183 | + r'|| true' % (name, name)): |
178 | 184 | # Filter out names in comment afer function,
|
179 | 185 | # when comment start from ' *'
|
180 | 186 | # To see the problem try "git grep -p and"
|
@@ -230,7 +236,7 @@ def referrers_tree(name, referrer=None, printed=None, level=0):
|
230 | 236 | '''
|
231 | 237 | prints text referrers outline.
|
232 | 238 | Ex: nfs_root_data
|
233 |
| - Ex2: srcxray.py referrers_tree X|srcxray.py reverse_graph |
| 239 | + Ex2: srcxray.py referrers_tree X | srcxray.py reverse_graph |
234 | 240 | Obsoleted by doxygen_xml.
|
235 | 241 | '''
|
236 | 242 | if not referrer:
|
@@ -265,7 +271,7 @@ def referrers(name):
|
265 | 271 | Ex: nfs_root_data
|
266 | 272 | Prefer to use doxygen_xml.
|
267 | 273 | '''
|
268 |
| - print(' '.join([a[2] for a in func_referrers_git_grep(name)])) |
| 274 | + print('\n'.join([a[2] for a in func_referrers_git_grep(name)])) |
269 | 275 |
|
270 | 276 |
|
271 | 277 | def referrers_dep(name, referrer=None, printed=None, level=0):
|
@@ -1196,7 +1202,6 @@ def import_symbols():
|
1196 | 1202 |
|
1197 | 1203 | me = os.path.basename(sys.argv[0])
|
1198 | 1204 |
|
1199 |
| - |
1200 | 1205 | def dir_tree(path='.'):
|
1201 | 1206 | '''
|
1202 | 1207 | scans directory into graph
|
@@ -1252,7 +1257,7 @@ def doxygen(*sources, output_dir='xml2'):
|
1252 | 1257 | #INTERACTIVE_SVG = YES
|
1253 | 1258 | #DOT_TRANSPARENT = YES
|
1254 | 1259 | #DOT_MULTI_TARGETS = NO
|
1255 |
| - #DOT_FONTNAME = Ubuntu |
| 1260 | + #DOT_FONTNAME = Helvetica |
1256 | 1261 | #CASE_SENSE_NAMES = YES
|
1257 | 1262 | SOURCE_BROWSER = NO
|
1258 | 1263 | GENERATE_HTML = YES
|
@@ -1559,7 +1564,6 @@ def test_1(self):
|
1559 | 1564 | self.assertFalse(0 == os.system(
|
1560 | 1565 | "grep DECLARE_COMPLETION call_graph_dx_files.dot"))
|
1561 | 1566 |
|
1562 |
| - |
1563 | 1567 | def main():
|
1564 | 1568 | global usage, stop
|
1565 | 1569 | try:
|
@@ -1591,6 +1595,7 @@ def main():
|
1591 | 1595 | log(sys.argv[1][2:])
|
1592 | 1596 | if sys.argv[1][2:] == 'verbose':
|
1593 | 1597 | verbose = True
|
| 1598 | + log(level_limit) |
1594 | 1599 | if sys.argv[1][2:] == 'level_limit':
|
1595 | 1600 | level_limit = int(sys.argv[2])
|
1596 | 1601 | sys.argv = sys.argv[1:]
|
|
0 commit comments