Skip to content

Commit e3fd6ab

Browse files
Costa ShulyupinCosta Shulyupin
Costa Shulyupin
authored and
Costa Shulyupin
committed
update
1 parent 4fd4267 commit e3fd6ab

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

srcxray.py

+19-14
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/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+
"""
79
# Uses doxygen, git grep --show-functionm and cscope to
810
# reveal references between identifiers.
911
#
@@ -34,7 +36,7 @@
3436
import difflib
3537
import glob
3638
from pathlib import *
37-
import pygraphviz # python3-pygraphviz
39+
import pygraphviz # sudo dnf install -yq python3-pygraphviz
3840
import graphviz # python3-graphviz
3941
import unittest
4042
import types
@@ -171,10 +173,14 @@ def func_referrers_git_grep(name):
171173
# Obsoleted by doxygen_xml.
172174
res = list()
173175
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 '
176180
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)):
178184
# Filter out names in comment afer function,
179185
# when comment start from ' *'
180186
# To see the problem try "git grep -p and"
@@ -230,7 +236,7 @@ def referrers_tree(name, referrer=None, printed=None, level=0):
230236
'''
231237
prints text referrers outline.
232238
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
234240
Obsoleted by doxygen_xml.
235241
'''
236242
if not referrer:
@@ -265,7 +271,7 @@ def referrers(name):
265271
Ex: nfs_root_data
266272
Prefer to use doxygen_xml.
267273
'''
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)]))
269275

270276

271277
def referrers_dep(name, referrer=None, printed=None, level=0):
@@ -1196,7 +1202,6 @@ def import_symbols():
11961202

11971203
me = os.path.basename(sys.argv[0])
11981204

1199-
12001205
def dir_tree(path='.'):
12011206
'''
12021207
scans directory into graph
@@ -1252,7 +1257,7 @@ def doxygen(*sources, output_dir='xml2'):
12521257
#INTERACTIVE_SVG = YES
12531258
#DOT_TRANSPARENT = YES
12541259
#DOT_MULTI_TARGETS = NO
1255-
#DOT_FONTNAME = Ubuntu
1260+
#DOT_FONTNAME = Helvetica
12561261
#CASE_SENSE_NAMES = YES
12571262
SOURCE_BROWSER = NO
12581263
GENERATE_HTML = YES
@@ -1559,7 +1564,6 @@ def test_1(self):
15591564
self.assertFalse(0 == os.system(
15601565
"grep DECLARE_COMPLETION call_graph_dx_files.dot"))
15611566

1562-
15631567
def main():
15641568
global usage, stop
15651569
try:
@@ -1591,6 +1595,7 @@ def main():
15911595
log(sys.argv[1][2:])
15921596
if sys.argv[1][2:] == 'verbose':
15931597
verbose = True
1598+
log(level_limit)
15941599
if sys.argv[1][2:] == 'level_limit':
15951600
level_limit = int(sys.argv[2])
15961601
sys.argv = sys.argv[1:]

0 commit comments

Comments
 (0)