8000 update tcmd direcotry to synchronize with taf directory · cheoljoo/doxygen_perlmod_python@7dfe8cf · GitHub
[go: up one dir, main page]

Skip to content

Commit 7dfe8cf

Browse files
author
charles.lee
committed
update tcmd direcotry to synchronize with taf directory
1 parent f050989 commit 7dfe8cf

File tree

10 files changed

+185
-45
lines changed

10 files changed

+185
-45
lines changed

taf/hpp2plantuml.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ def parse_members(self, header_container):
119119
#self._parent = re.sub('[<>]', '', parent['name'])
120120
self._parent = '::'.join(self._name.split('::')[:-1])
121121
p = parent
122-
while p.get('parent') is not None:
123-
p = p.get('parent', None)
124-
self._namespace = p['namespace']
122+
if isinstance(p,(dict,Class,Enum)):
123+
while p.get('parent') is not None:
124+
p = p.get('parent', None)
125+
self._namespace = p['namespace']
125126
self._do_parse_members(header_container)
126127

127128
def _do_parse_members(self, header_container):

taf/p.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
rm -rf _doc_* DoxyDocs.pm DoxyDocs.py
2+
rm -rf /home/cheoljoo.lee/temp/report-doc/*
3+
python3 runParallel.py --inDir=../services --outReportDir=/home/cheoljoo.lee/temp/report-doc --parallel

taf/run.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
rm -rf _doc_* DoxyDocs.pm DoxyDocs.py
2+
rm -rf /home/cheoljoo.lee/temp/report-doc/*
13
python3 runParallel.py --inDir=../services --outReportDir=/home/cheoljoo.lee/temp/report-doc --variant="_variant"

taf/taf_run_in_docker.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ echo "DOCKER_OUT ${DOCKER_OUT}"
88
echo "DOCKER_MODULE ${DOCKER_MODULE}"
99
#ls -l ${DOCKER_OUT}
1010
cd ${DOCKER_GIT}; python3 hpp2plantuml.py --input-directory=${DOCKER_IN} -o all.puml -j out.json
11-
cd ${DOCKER_GIT}; python3 sample-mako.py --infile=class.mako --service="${DOCKER_MODULE} Service" --plantumlServerProxy="http://tiger02.lge.com:18080/proxy?fmt=svg" --tcmdoutdir=${DOCKER_OUT}
11+
cd ${DOCKER_GIT}; python3 sample-mako.py --infile=class.mako --service="${DOCKER_MODULE}" --plantumlServerProxy="http://tiger02.lge.com:18080/proxy?fmt=svg" --tcmdoutdir=${DOCKER_OUT}

tcmd/Makefile

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,31 @@ endif
2424
@echo "FILE_HTTP = ${FILE_HTTP}"
2525
@echo "MODULE = ${MODULE}"
2626
@echo "FILES = ${FILES}"
27+
rm -rf _hpp_ _all_
28+
rm -rf _output_ _plantuml
29+
python3 copyFile.py --inDir=${INDIR} --startDirname="" --endExt="hpp,hxx,h" --destDir="_hpp_"
2730
if [ ! -e mysetting.py ]; then cp -f ../src/mysetting_example.py mysetting.py; fi
2831
#mkdir -p ${OUTDIR}/hpp
293 F438 2
#find ${INDIR} \( -name "*.h" -o -name "*.hpp" \) -exec cp -f {} ${OUTDIR}/hpp \;
30-
rm -rf _hpp_ _output_ _plantuml
3133
mkdir -p _hpp_
32-
make copy
33-
doxygen
34+
#make copy
35+
doxygen > doxygen_perlmod_python.log 2>&1 # _hpp_
3436
echo "DoxyDocs.pm is used for this document"
3537
cp -f _output_/perlmod/DoxyDocs.pm .
3638
perl doxy2py.pl
39+
mkdir -p ${OUTDIR}
3740
#git clone for doxygen_perlmod_python in ${GITDIR}
3841
#copy from ${INDIR} , Doxyfile to ${OUTDIR}/md/module/basename/hhh (header)
3942
#gen doxygen to ${OUTDIR}/md/module/basename/hhh/output (doxygen)
4043
#copy from ${INDIR} to ${OUTDIR}/md/module/basename/class.mako.html
4144
#copy doxygen _output_ (DoxyDocs.pm) to ${OUTDIR}/md/module/basename
4245
# do run the following things
43-
python3 hpp2plantuml.py $(shell find ${INDIR} \( -name "*.h" -o -name "*.hpp" \) -print0 | xargs -0 -n 1 echo -i) -o all.puml -j out.json
46+
python3 hpp2plantuml.py --input-directory=_hpp_ -o all.puml -j out.json
47+
#python3 hpp2plantuml.py $(shell find ${INDIR} \( -name "*.h" -o -name "*.hpp" \) -print0 | xargs -0 -n 1 echo -i) -o all.puml -j out.json
4448
# if we use -j option in hpp2plantuml , parse_hpp2plantuml.py is useless.
4549
#python3 parse_hpp2plantuml.py --inpuml=all.puml --outjson=parse-out.json
46-
python3 sample-mako.py --infile=class.mako --service="${MODULE} Service" --plantumlServerProxy="http://tiger02.lge.com:18080/proxy?fmt=svg" --fileHttpUrl=${FILE_HTTP} --tcmdoutdir=${OUTDIR}
50+
python3 sample-mako.py --infile=class.mako --service="${MODULE} Service" --plantumlServerProxy="http://tiger02.lge.com:18080/proxy?fmt=svg" --tcmdoutdir=${OUTDIR}
51+
if [ -e doxygen_perlmod_python.log ]; then echo "copy doxygen_perlmod_python.log ${OUTDIR}"; cp -f doxygen_perlmod_python.log ${OUTDIR} ; fi
4752

4853
copy: $(FILES)
4954
@mkdir -p $(DEST_DIR)

tcmd/class.mako

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,33 @@ import json
55
ret = '<br>'
66
pumlFileCount = 1
77
8+
def existProxyPlantuml(pfile):
9+
ans = ''
10+
fileList = pfile.split('/')
11+
dir = '/'.join(fileList[:-1])
12+
file = fileList[-1]
13+
nsList = file.split('::')
14+
match = ''
15+
for i in range(len(nsList)):
16+
#print('file', os.path.join(dir,'::'.join(nsList[i:])) )
17+
if os.path.exists(os.path.join(dir,'::'.join(nsList[i:]))):
18+
match = os.path.join(dir,'::'.join(nsList[i:]))
19+
#print('matched', os.path.join(dir,'::'.join(nsList[i:])) )
20+
break
21+
#print('return', match)
22+
return match
23+
824
def getProxyPlantuml(pfile,D):
925
global pumlFileCount
1026
html = ''
1127
if os.path.exists(pfile):
12-
proxylink = '{proxy}&src={phttp}/{file}'.format(proxy=D['_template__']['myPlantumlServerProxy'] , phttp=D['_template__']['mySrcDirHttp']+'/'+D['_template__']['tcmdoutdir'] if D['_template__']['tcmdoutdir'] else D['_template__']['mySrcDirHttp'], file=pfile.split('/')[-1])
13-
html += '''<img id="Image{c}" src="" alt="{pfile}")><br>'''.format(c=pumlFileCount,proxylink=proxylink,pfile=pfile)
28+
#proxylink = '{proxy}&src={phttp}/{file}'.format(proxy=D['_template__']['myPlantumlServerProxy'] , phttp=D['_template__']['mySrcDirHttp']+'/'+D['_template__']['tcmdoutdir'] if D['_template__']['tcmdoutdir'] else D['_template__']['mySrcDirHttp'], file=pfile.split('/')[-1])
29+
html += '''<img id="Image{c}" src="" alt="{pfile}")><br>'''.format(c=pumlFileCount,pfile=pfile)
1430
D['_template__']['files'].append(pfile)
1531
#print('html',html, 'pfile',pfile)
1632
pumlFileCount += 1
33+
else:
34+
html += '''<!-- pfile : {p} is not exist -->\n'''.format(p=pfile)
1735
return html
1836
1937
def getParameters(parameters,detailed_doc):
@@ -314,10 +332,12 @@ ${ getProxyPlantuml('_plantuml/_all_puml.puml',D) }
314332
% if len( [ accessibility for accessibility,v2 in v.items() if accessibility == 'public_methods'] ):
315333
<% classCnt += 1 %>\
316334
<h1>${classCnt}. ${v['name']} class</h1>
317-
% if os.path.exists('_plantuml/{c}_puml.puml'.format(c=v['name'])):
335+
<% matchedPlantuml = existProxyPlantuml('_plantuml/{c}_puml.puml'.format(c=v['name'])) %>
336+
<!-- existProxyPlantuml : _plantuml/${ v['name'] }_puml.puml -> ${matchedPlantuml} -->
337+
% if matchedPlantuml:
318338
<% classSubCntL2 += 1 %>
319339
<h2>${classCnt}.${classSubCntL2}. class diagram</h2>
320-
${ getProxyPlantuml('_plantuml/{c}_puml.puml'.format(c=v['name']),D) }
340+
${ getProxyPlantuml(matchedPlantuml,D) }
321341
% endif
322342

323343
<% classSubCntL2 += 1 %>
@@ -361,12 +381,13 @@ ${ getProxyPlantuml('_plantuml/_all_puml.puml',D) }
361381
% if detailsType == 'plantuml':
362382
<%
363383
plantumlCnt += 1
364-
with open('_test-{c}.puml'.format(c=plantumlCnt),'w') as f:
365-
f.write('@startuml _test-{c}.png\n'.format(c=plantumlCnt))
384+
print('write: _plantuml/_class_detail-{c}.puml'.format(c=plantumlCnt))
385+
with open('_plantuml/_class_detail-{c}.puml'.format(c=plantumlCnt),'w') as f:
386+
f.write('@startuml _class_detail-{c}.png\n'.format(c=plantumlCnt))
366387
f.write(detailsContent)
367388
f.write('\n@enduml\n')
368389
%>
369-
${ getProxyPlantuml("_test-{c}.puml".format(c=plantumlCnt),D) }
390+
${ getProxyPlantuml("_plantuml/_class_detail-{c}.puml".format(c=plantumlCnt),D) }
370391
% else:
371392
${ detailsContent } <br>
372393
% endif
@@ -416,12 +437,13 @@ ${ getProxyPlantuml('_plantuml/_all_puml.puml',D) }
416437
% if detailsType == 'plantuml':
417438
<%
418439
plantumlCnt += 1
419-
with open('_test-{c}.puml'.format(c=plantumlCnt),'w') as f:
420-
f.write('@startuml _test-{c}.png\n'.format(c=plantumlCnt))
440+
print('write: _plantuml/_member_detail-{c}.puml'.format(c=plantumlCnt))
441+
with open('_plantuml/_member_detail-{c}.puml'.format(c=plantumlCnt),'w') as f:
442+
f.write('@startuml _member_detail-{c}.png\n'.format(c=plantumlCnt))
421443
f.write(detailsContent)
422444
f.write('\n@enduml\n')
423445
%>
424-
${ getProxyPlantuml("_test-{c}.puml".format(c=plantumlCnt),D) }
446+
${ getProxyPlantuml("_plantuml/_member_detail-{c}.puml".format(c=plantumlCnt),D) }
425447
% else:
426448
${ detailsContent } <br>
427449
% endif
@@ -447,7 +469,6 @@ window.onload = function() {
447469
var newSrc = urlSegments.join("/");
448470
var newSrc2 = "http://tiger02.lge.com:18080/proxy?fmt=svg&src=" + newSrc;
449471
img.src = newSrc2;
450-
//img.src = aa[count]; // Array는 0부터 시작하므로, count에서 1을 빼줍니다.
451472
}
452473
}
453474
</script>

tcmd/copyFile.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import sys,os
2+
sys.path.append(os.getcwd())
3+
import argparse
4+
import json
5+
import shutil
6+
7+
if (__name__ == "__main__"):
8+
parser = argparse.ArgumentParser(
9+
prog=sys.argv[0],
10+
description=
11+
'copy file to <specific-dir> : starts with <specific-dirname> and ends with <specific-extension>'
12+
)
13+
parser.add_argument( '--inDir',
14+
metavar="<str>",
15+
type=str,
16+
default='core/service',
17+
help='starting directory for searching')
18+
parser.add_argument( '--startDirname',
19+
metavar="<str>",
20+
type=str,
21+
default='service,include,interface',
22+
help='several starting directory name with comma in <inDir>')
23+
parser.add_argument( '--endExt',
24+
metavar="<str>",
25+
type=str,
26+
default='h,hpp,hxx',
27+
help='several extension with comma in <inDir>')
28+
parser.add_argument( '--destDir',
29+
metavar="<str>",
30+
type=str,
31+
default='_hpp_',
32+
help='output directory for tcmd to gather serviced files')
33+
args = parser.parse_args()
34+
35+
os.makedirs(args.destDir,exist_ok=True)
36+
startList = [ x.strip() for x in args.startDirname.split(',') ]
37+
extList = [ x.strip() for x in args.endExt.split(',') ]
38+
39+
excludeList = ['mock','unittest','uts']
40+
filecnt = 0
41+
if args.inDir.find('telephony-service') >= 0 :
42+
startList = ['']
43+
for s in startList:
44+
for root , dirs,files in os.walk(args.inDir + '/' + s):
45+
print(root,files)
46+
for file in files:
47+
exclFlag = False
48+
for excl in excludeList:
49+
if file.lower().find(excl) >= 0:
50+
exclFlag = True
51+
break
52+
if exclFlag :
53+
continue
54+
if file.split('.')[-1] in extList:
55+
print('copy',os.path.join(root, file), args.destDir)
56+
filecnt += 1
57+
shutil.copy(os.path.join(root, file), args.destDir)
58+
59+
print(sys.argv[0] , 'copy file count :',filecnt)
60+
print(sys.argv[0] , 'copy file count :',filecnt , file=sys.stderr)

tcmd/doxy2py.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ ($$)
3232
foreach $key (keys %{$doc}) {
3333
if( not ( (${$doc}{$key} =~ /^ARRAY\(/) || (${$doc}{$key} =~ /^HASH\(/) ) ){
3434
#print "hash $str { $key } = value( ${$doc}{$key} )\n";
35-
print PH "$ps ['$key'] = \'\'\'" . change_special_code(${$doc}{$key}) . "\'\'\'\n";
35+
if( change_special_code(${$doc}{$key}) =~ /'$/){
36+
print PH "$ps ['$key'] = \"\"\"" . change_special_code(${$doc}{$key}) . "\"\"\"\n";
37+
} else {
38+
print PH "$ps ['$key'] = \'\'\'" . change_special_code(${$doc}{$key}) . "\'\'\'\n";
39+
}
3640
#print PH "$ps ['$key'] = \"" . change_special_code(${$doc}{$key}) . "\"\n";
3741
} else {
3842
generate_cc("$str { $key }", ${$doc}{$key});

tcmd/hpp2plantuml.py

Lines changed: 62 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def __init__(self, container_type, name):
8181
self._puml = ''
8282
self._filename = ''
8383
self._inheritance_list = []
84+
self._abstract = False
85+
self._template_type = None
8486

8587
@property
8688
def name(self):
@@ -117,9 +119,10 @@ def parse_members(self, header_container):
117119
#self._parent = re.sub('[<>]', '', parent['name'])
118120
self._parent = '::'.join(self._name.split('::')[:-1])
119121
p = parent
120-
while p.get('parent') is not None:
121-
p = p.get('parent', None)
122-
self._namespace = p['namespace']
122+
if isinstance(p,(dict,Class,Enum)):
123+
while p.get('parent') is not None:
124+
p = p.get('parent', None)
125+
self._namespace = p['namespace']
123126
self._do_parse_members(header_container)
124127

125128
def _do_parse_members(self, header_container):
@@ -1099,11 +1102,18 @@ def parse_objects(self, header_file, arg_type='string'):
10991102
otherwise, it is assumed to be a filename
11001103
"""
11011104
# Parse header file
1102-
parsed_header = CppHeaderParser.CppHeader(header_file,
1105+
try:
1106+
parsed_header = CppHeaderParser.CppHeader(header_file,
11031107
argType=arg_type)
1108+
except Exception as e:
1109+
ae = str(e)
1110+
ae = ae.replace('rror','_r_r_o_r')
1111+
print('CppHeaderParser',ae)
1112+
return
11041113
#print('parsed_header keys',list(parsed_header.__dict__.keys()))
11051114
#pprint({'parsed_header':parsed_header.__dict__})
11061115
#pprint({'parsed_header.classes':parsed_header.classes})
1116+
#print('parsed_header')
11071117
for container_type, (container_iterator,
11081118
container_handler) in CONTAINER_TYPE_MAP.items():
11091119
objects = parsed_header.__getattribute__(container_type)
@@ -1417,15 +1427,17 @@ def render(self):
14171427
for obj in self._nesting_list:
14181428
jjson['nesting'].append(obj.__dict__)
14191429
# debugging try exception for json
1430+
'''
14201431
try:
14211432
json_string = json.dumps(jjson['objects'],cls=ComplexEncoder)
14221433
json_string = json.dumps(jjson['inherit'], cls=ComplexEncoder)
14231434
json_string = json.dumps(jjson['aggregation'], cls=ComplexEncoder)
14241435
json_string = json.dumps(jjson['dependency'], cls=ComplexEncoder)
14251436
json_string = json.dumps(jjson['nesting'], cls=ComplexEncoder)
14261437
except TypeError as e:
1427-
print(f"Serialization error: {e}")
1428-
quit(4)
1438+
print(f"Serialization e_r_r_o_r: {e}")
1439+
#quit(4)
1440+
'''
14291441
return render , jjson
14301442

14311443
# %% Cleanup object type string
@@ -1619,7 +1631,7 @@ def CreatePlantUMLFile(file_list, output_file=None, output_json_file=None, **dia
16191631
traverse_objects(output_diag_json,tt,0)
16201632
diag_json['objects'] = output_diag_json
16211633
make_inheritance_unknown(diag_json)
1622-
if output_json_file:
1634+
if output_json_file and False:
16231635
with open(output_json_file, 'w') as fid:
16241636
json.dump(diag_json,fid,indent = 4,cls=ComplexEncoder)
16251637

@@ -1709,14 +1721,37 @@ def create_plantuml_file(dj = [], focus_class='',puml_kind='_puml_nomember',exce
17091721

17101722
if focus_class:
17111723
#print(focus_class)
1712-
puml += dj['objects'][class_name_index[focus_class]]['_container_type'] + ' ' + focus_class + ' #GreenYellow/LightGoldenRodYellow\n'
1724+
def get_container_type(d):
1725+
if d['_container_type'] in ['struct', 'union']:
1726+
container_type = 'class'
1727+
else:
1728+
container_type = d['_container_type']
1729+
class_str = container_type
1730+
abstract = False
1731+
template_type = None
1732+
if isinstance(d,dict):
1733+
abstract = d.get('_abstract',False)
1734+
template_type = d.get('_template_type',None)
1735+
else:
1736+
abstract = d._abstract
1737+
template_type = d._template_type
1738+
if abstract:
1739+
class_str = 'abstract ' + class_str
1740+
if template_type:
1741+
class_str += ' <{0}>'.format(template_type)
1742+
return class_str
1743+
1744+
#puml += dj['objects'][class_name_index[focus_class]]['_container_type'] + ' ' + focus_class + ' #GreenYellow/LightGoldenRodYellow\n'
1745+
#print('dj',dj['objects'][class_name_index[focus_class]])
1746+
#print(focus_class)
1747+
puml += get_container_type(dj['objects'][class_name_index[focus_class]]) + ' ' + focus_class + ' #GreenYellow/LightGoldenRodYellow\n'
17131748
puml += '@enduml\n'
17141749

17151750
#print(puml)
17161751

17171752
outfile = '{d}/{f}.puml'.format(d=PLANTUML_DIRECTORY,f=file)
17181753
with open(outfile,'w') as f:
1719-
print('write:',outfile)
1754+
#print('write:',outfile)
17201755
f.write(puml)
17211756

17221757

@@ -1737,7 +1772,7 @@ def make_inheritance_unknown(dj):
17371772
child = p['_child'].split('::')[-1]
17381773
parent = p['_parent'].split('::')[-1]
17391774
inherit_pair.append( [child,parent] )
1740-
pprint(inherit_pair)
1775+
if debug : pprint( { 'inherit_pair':inherit_pair } )
17411776
for o in dj['objects']:
17421777
'''
17431778
print(type(o))
@@ -1759,7 +1794,7 @@ def make_inheritance_unknown(dj):
17591794
#print('..' , inheritance)
17601795
parent = inheritance.split('::')[-1]
17611796
if [child,parent] not in inherit_pair:
1762-
print('unknown:', [child,parent] , o['_name'] , inheritance)
1797+
if debug : print('unknown:', [child,parent] , o['_name'] , inheritance)
17631798
dj['inherit_unknown'].append( {
17641799
'_parent' : inheritance ,
17651800
'_child' : o['_name'] ,
@@ -1804,8 +1839,11 @@ def main():
18041839
Arguments are read from the command-line, run with ``--help`` for help.
18051840
"""
18061841
parser = argparse.ArgumentParser(description='hpp2plantuml tool.')
1842+
parser.add_argument('--input-directory', dest='input_directory',
1843+
action='append', metavar='HEADER-FILE-DIRECTORY',
1844+
help='input file directory')
18071845
parser.add_argument('-i', '--input-file', dest='input_files',
1808-
action='append', metavar='HEADER-FILE', required=True,
1846+
action='append', metavar='HEADER-FILE',
18091847
help='input file (must be quoted' +
18101848
' when using wildcards)')
18111849
parser.add_argument('-o', '--output-file', dest='output_file',
@@ -1827,6 +1865,18 @@ def main():
18271865
parser.add_argument('--version', action='version',
18281866
version='%(prog)s ' + '0.8.4')
18291867
args = parser.parse_args()
1868+
1869+
if not args.input_files:
1870+
args.input_files = []
1871+
if args.input_directory:
1872+
for d in args.input_directory:
1873+
ow = os.walk(d)
1874+
for root, dirs, files in ow:
1875+
for file in files:
1876+
if file.split('.')[-1] in ['hpp','h','hxx']:
1877+
args.input_files.append(os.path.join(root, file))
1878+
1879+
# print('input_files',args.input_files)
18301880
if len(args.input_files) > 0:
18311881
flag_json = True if args.output_json_file else False
18321882
if args.focus_class.strip():

0 commit comments

Comments
 (0)
0