def readDOXYGEN(ilines,icount,lname,list,move): # ~~ Parsers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ olines = [] doxy_char = '!> @'; doxy_cont_char = '!>' temp_char = '!' ; cont_char = '!+' htmldico = ['<table>','</table>','<tr>','</tr>','<th>','</th>','<td>','</td>','</center>'] for name,doxy,docs,body,vars in parseDoxyWrap(ilines,icount): history = [] who = list[lname][name] #reformats development history if doxy['hist'] != []: for i in range(len(doxy['hist'])) : for format in htmldico : doxy['hist'][i] = doxy['hist'][i].replace(format,'') i = 0 while i < len(doxy['hist']) : if '<center>' in doxy['hist'][i] : release = doxy['hist'][i].strip(doxy_cont_char).strip().strip('<center>').strip() if len(release.split('.')) > 1 : release = ' V' + release.split('.')[0] + 'P' + release.split('.')[1] date = doxy['hist'][i+1].strip(doxy_cont_char) name = doxy['hist'][i+2].strip(doxy_cont_char) for j in [0,1,2,3,4,5,6,7,8,9] : #deletes the telephone number name = name.replace(str(j),'') for j in ['....','...','----','---'] : name = name.replace(j,'') note = doxy['hist'][i+3].strip(doxy_cont_char) i = i+4 history.append([name,date,release,note]) else : i = i+1 #writes out docs (with some formatting) e.g. olines.extend(['!'+20*' '+len(docs[0].strip())*'*'+'\n']) #! ***************** olines.extend([' '+20*' '+docs[0].strip()+'\n']) # SUBROUTINE CORFON olines.extend(['!'+20*' '+len(docs[0].strip())*'*'+'\n']) #! ***************** olines.extend(['!']) #! for i in range(1,len(docs),1) : olines.extend([docs[i]]) olines.extend(['!']) #! olines.extend(['!'+71*'*'+'\n']) #!*********************************************************************** line = '! '+lname.upper() if history != [] : line = line+' '+history[0][2]+ \ 30*' '+history[0][1]+'\n' olines.append(line) #! ARTEMIS V6P0 21/08/2010 olines.extend(['!'+71*'*'+'\n'+'!\n']) #!*********************************************************************** #adds tags # ~~ Function and User Defined Information #file = []; hist = []; fcts = []; bugs = []; warn = []; note = []; refs = []; code = []; para = []; resu = [] for info in ['file','fcts','note','warn','bugs','refs','code'] : if doxy[info] != [] : tmp = [] doxy[info][0] = doxy[info][0].replace('<br>','\n'+cont_char) doxy[info][0] = doxy[info][0].replace(doxy_char, temp_char) tmp.extend(doxy[info][0].split(' ',1)) #formats the tags such that descriptions is 10char. from margin line = tmp[0] if len(tmp) > 1 : if info <> 'refs' : line = line+(10-len(tmp[0]))*' '+tmp[1].strip() else : line = line+2*' '+tmp[1].strip() olines.append(line) for i in range(1,len(doxy[info]),1) : doxy[info][i] = doxy[info][i].replace('<br>','\n'+cont_char) doxy[info][i] = doxy[info][i].replace(doxy_char, temp_char) doxy[info][i] = doxy[info][i].replace(doxy_cont_char, cont_char) if doxy[info][i] <> '!endcode' : olines.append(doxy[info][i]) olines.extend([temp_char+'\n']) # ~~ Development History if history != []: #writes them back in reverse order and keeps empty lines when no information is supplied #earlier version had if "history[i][1].strip() <> '' :" which only displayed relevant information #it got a bit tricky to doxygenise (recognise a date from a comment) #this will hopefully be covered by new script with pop-up window requiring the user to fill-in #metadata at the SVN commission stage for i in range(len(history)-1,-1,-1) : #writes them back olines.extend(['!history'+2*' '+history[i][0].strip()]) olines.extend([cont_char+8*' '+history[i][1].strip()]) #if history[i][1].strip() <> '' : olines.extend([cont_char+8*' '+history[i][2].strip()]) #if history[i][2].strip() <> '' : #if history[i][3].strip() <> '' : #lines limited to 69char history[i][3] = history[i][3].replace('<br>',' '+cont_char+' ') #+cont_char+' ') note = history[i][3].strip().split() while 1 : l = 0; j = 0 while j <= len(note)-1 and l <= 65 and note[j] != cont_char : l = l + len(note[j]) + 1 j = j+1 if j != len(note) and note[j] != cont_char: #l>65 broke the while loop j = j-1 line = cont_char + 3*' ' for k in range(j) : line = line + note[0] + ' ' note.pop(0) olines.append(line) if note != [] and note[0] == cont_char : #note[j]=cont_char broke the while loop note.pop(0) olines.append(cont_char) if note == [] or (len(note) == 1 and note[0] == '') : break olines.extend(['!\n']) olines.extend(['!'+71*'~'+'\n']) #concatenates vars (with some formatting) and body to re-write fortran code #!!! if the variables in the in/out table are not in argument, move description #!!! to declarations_[code].f if in "use" (dico move), delete otherwise (local) # ~~ Arguments for k in vars.keys() : #eg 'T1,2' found = True k_list = k.split(',') #eg ['T1','2'] for item in k_list : #eg 'T1' if item not in who['args'] : found = False # ~~ Uses if who['vars']['use'] != {}: for u in who['vars']['use']: if item in who['vars']['use'][u]: mfile = list[mdl[u][0]][u]['path']+sep+u.lower() if mfile not in move.keys(): move.update({mfile:[]}) move[mfile].append([item,temp_char+' '+' '.join(vars[k][1])]) if not found : del vars[k] for v in sorted(vars.keys()): name = v + 14*' ' ino = ['-','-','-'] if '<' in vars[v][0]: ino[0] = '<' if '>' in vars[v][0]: ino[2] = '>' line = '!| ' + name[0:15] + '|' + ''.join(ino) + '| ' + '\n!| | | '.join(vars[v][1]) olines.extend([line]) olines.extend(['!'+71*'~'+'\n']) olines.extend(['!\n']) # ~~ Main Body of Source Code count = 0 while count < len(body) : proc = re.match(f77continu2,body[count]) if proc: body[count] = ' &'+body[count][6:] #sets all continuation characters to & proc = re.match(f77comment,body[count]) if proc: body[count] = '!'+body[count][1:] #sets all comment characters to ! proc = re.match(brief,body[count]) if proc: body[count] = '!brief'+proc.group('after') #replaces !> @brief with !brief in modules olines.append(body[count]) count = count+1 return olines,move
def createDOXYGEN(ifile,ilines,lname,list): # ~~ Parsers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ olines = [] for name,subname,doxy,body in parseDoxyWrap(ilines): print ' +> ',path.basename(ifile), subname, name who = list[lname][subname] # ~~ General olines.append(ifile + '\n!') #line = '!> @code\n' #if who['type'] == 'S': line = line + '!> SUBROUTINE\n' #if who['type'] == 'M': line = line + '!> MODULE\n' #if who['type'] == 'P': line = line + '!> PROGRAM\n' #if who['type'] == 'F': line = line + '!> FUNCTION\n' #line = line + '!> NAME : ' + who['name'] + '\n' \ # '!> MODULE : ' + who['libname'] + '\n' #line = line + '!> @endcode\n' #olines.append(line) # ~~ Module olines.append('!> @par Module: '+who['libname']+'\n!') for d in doxy: # ~~ Brief if d[0] == 'brief': line = '!> @brief\n!> ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line+'\n!') # ~~ User Defined Information if d[0] == 'note' or d[0] == 'warn' or d[0] == 'refs' or d[0] == 'code': if d[0] == 'note': line = '!> @note\n!> ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line+'\n!') if d[0] == 'bug': line = '!> @bug\n!> ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line+'\n!') if d[0] == 'warn': line = '!> @warning\n!> ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line+'\n!') if d[0] == 'refs': line = '!> @reference\n!> ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line+'\n!') if d[0] == 'code': line = '!> @code\n!> ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line + '\n!> @endcode\n!') # ~~ Final Uses ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if who['uses'] != {}: line = '!> @par Use(s)\n!><br>' + ', '.join(sorted(who['uses'].keys())) olines.append(line+'\n!') # ~~ Final Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if who['args'] != [] or who['vars']['use'] != {} or who['vars']['cmn'] != [] or who['vars']['dec'] != [] or who['vars']['als'] != []: line = '!> @par Variable(s)\n!> <br><table>' olines.append(line) # ~~ Arguments if who['args'] != []: line = '!> <tr><th> Argument(s)\n!> </th><td> ' + ', '.join(sorted(who['args'])) + '\n!> </td></tr>' olines.append(line) # ~~ Uses if who['vars']['use'] != {}: line = '!> <tr><th> Use(s)\n!> </th><td>' for u in who['vars']['use']: uv = [] for v in who['vars']['use'][u]: uv.append('\n!> @link ' + u + '::' + v + ' ' + v + '@endlink') line = line + '<hr>\n!> ' + u + ' :<br>' + ', '.join(sorted(uv)) line = line.replace('<td><hr>\n','<td>\n') + '\n!> </td></tr>' olines.append(line) # ~~ Commons if who['vars']['cmn'] != []: line = '!> <tr><th> Common(s)\n!> </th><td>' for u in who['vars']['cmn']: line = line + '<hr>\n!> ' + u[0] + ' : ' + ', '.join(u[1]) line = line.replace('<td><hr>\n','<td>\n') + '\n!> </td></tr>' olines.append(line) # ~~ Declars if who['vars']['dec'] != []: line = '!> <tr><th> Internal(s)\n!> </th><td> ' + ', '.join(sorted(who['vars']['dec'])) + '\n!> </td></tr>' olines.append(line) # ~~ Externals #if who['vars']['xtn'] != []: # line = '!> <tr><th> External(s)\n!> </th><td> ' + ', '.join(sorted(who['vars']['xtn'])) + '\n!> </td></tr>' # olines.append(line) # ~~ Aliases if who['vars']['als'] != []: line = '!> <tr><th> Alias(es)\n!> </th><td> ' + ', '.join(sorted(who['vars']['als'])) + '\n!> </td></tr>' olines.append(line) line = '!> </table>\n!' olines.append(line) # ~~ Final Calls ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if who['calls'] != {} or who['functions'] != []: line = '!> @par Call(s)\n!> <br><table>' olines.append(line) if who['calls'] != {}: line = '!> <tr><th> Known(s)\n!> </th><td> ' + '(), '.join(sorted(who['calls'].keys())) + '()\n!> </td></tr>' olines.append(line) if who['functions'] != []: line = '!> <tr><th> Unknown(s)\n!> </th><td> ' + ', '.join(sorted(who['functions'])) + '\n!> </td></tr>' olines.append(line) line = '!> </table>\n!' olines.append(line) # ~~ Final Called ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ if who['called'] != []: line = '!> @par Called by\n!><br>' + '(), '.join(sorted(who['called'])) + '()\n!' olines.append(line) # ~~ Final History ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for d in doxy: # ~~ Other pars if d[0] == 'para': line = '!> @par ' + '\n!> '.join(d[1]) line.replace('\n!> \n','\n!> <br><br>\n') olines.append(line+'\n') # ~~ Result if d[0] == 'result': line = '!> @par Result ' + '\n!> '.join(d[1]) olines.append(line+'\n!') # ~~ Final History ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ hist = False for d in doxy: if d[0] == 'history': hist = True if hist: olines.append('!> @par Development history') olines.append('!> <br><table>') olines.append('!> <tr><th> Release </th><th> Date </th><th> Author </th><th> Notes </th></tr>') for d in doxy: if d[0] == 'history': olines.append('!> <tr><td><center> ' + d[1][2] +' </center>') olines.append('!> </td><td> ' + d[1][1]) olines.append('!> </td><td> ' + d[1][0]) if len(d[1]) > 3: olines.append('!> </td><td> ' + d[1][3]) else: olines.append('!> </td><td> ') print '\nHistory comment missing in: ' + subname + '\n' olines.append('!> </td></tr>') olines.append('!> </table>\n!') # ~~ Extended Description #if vars.keys() != '' or who['args'] != '': # for a in who['args']: # found = False # for v in vars.keys(): # if a in parseVars(v): found = True # if not found: vars.update({a:['',['']]}) # olines.extend(['!> @par Details of primary variable(s)\n!> <br><table>']) # #olines.extend(['!> <p><div id="dynsection-1" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;"> \ # # \n!> <img id="dynsection-1-trigger" src="closed.png"> Here are details of primary variables:</div> \ # # \n!> <div id="dynsection-1-summary" class="dynsummary" style="display:block;"> \ # # \n!> </div> \ # # \n!> <div id="dynsection-1-content" class="dyncontent" style="display:none;">']) # olines.extend(['!>\n!> <tr><th>Name(s)</th><th>(in-out)</th><th>Description</th></tr>']) # for v in sorted(vars.keys()): # #print v,vars[v][1] # ino = ['-','-','-'] # if '<' in vars[v][0]: ino[0] = '<' # if '>' in vars[v][0]: ino[2] = '>' # line = '!> <tr><td>' + v + '\n!></td><td>' + ''.join(ino) + '</td><td>' + '\n!> '.join(vars[v][1]) + '\n!> </td></tr>' # olines.extend([line]) # olines.extend(['!> </table>']) # #olines.extend(['!> </div></p>']) #~~~~~~~~~> #for count in range(len(docs)): # proc = re.match(f77continu2,docs[count]) # if proc: docs[count] = ' &'+docs[count][6:] #~~~~~~~~~< #olines.extend(docs) # ~~ Final Tempates ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #olines.extend(['C\nC'+71*'~']) #for v in sorted(vars.keys()): # name = v + ' ' # ino = ['-','-','-'] # if '<' in vars[v][0]: ino[0] = '<' # if '>' in vars[v][0]: ino[2] = '>' # line = 'C| ' + name[0:15] + '|' + ''.join(ino) + '| ' + '\nC| | | '.join(vars[v][1]) # olines.extend([line]) #olines.extend(['C'+71*'~'+'\nC']) # ~~ Unchanged ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ for line in body: olines.append(line) return olines