scripts/bib2dox.py
changeset 798 f5f260a63a9b
parent 790 94ef0a5c0005
child 801 2de0fc630899
equal deleted inserted replaced
0:fd2ab6d67a38 1:b4f0d412542a
    84 field_rex = re.compile('\s*(\w*)\s*=\s*(.*)')
    84 field_rex = re.compile('\s*(\w*)\s*=\s*(.*)')
    85 data_rex = re.compile('\s*(\w*)\s*=\s*([^,]*),?')
    85 data_rex = re.compile('\s*(\w*)\s*=\s*([^,]*),?')
    86 
    86 
    87 url_rex = re.compile('\\\url\{([^}]*)\}')
    87 url_rex = re.compile('\\\url\{([^}]*)\}')
    88 
    88 
       
    89 #
       
    90 # styles for html formatting
       
    91 #
       
    92 divstyle = 'margin-top: -4ex; margin-left: 8em;'
    89 
    93 
    90 #
    94 #
    91 # return the string parameter without braces
    95 # return the string parameter without braces
    92 #
    96 #
    93 def transformurls(str):
    97 def transformurls(str):
   282         # want @<alphanumeric chars><spaces>{<spaces><any chars>,
   286         # want @<alphanumeric chars><spaces>{<spaces><any chars>,
   283             entrycont = {}
   287             entrycont = {}
   284             entry = []
   288             entry = []
   285             entrytype = pubtype_rex.sub('\g<1>',line)
   289             entrytype = pubtype_rex.sub('\g<1>',line)
   286             entrytype = string.lower(entrytype)
   290             entrytype = string.lower(entrytype)
   287             # entryid   = pubtype_rex.sub('\g<2>', line)
   291             entryid   = pubtype_rex.sub('\g<2>', line)
   288 
   292 
   289         # end entry if just a }
   293         # end entry if just a }
   290         elif endtype_rex.match(line):
   294         elif endtype_rex.match(line):
   291             # generate doxygen code for the entry
   295             # generate doxygen code for the entry
   292 
   296 
   377             if entrycont.has_key('key'):
   381             if entrycont.has_key('key'):
   378                 sortkey = entrycont['key'] + sortkey
   382                 sortkey = entrycont['key'] + sortkey
   379                 bibkey = entrycont['key']
   383                 bibkey = entrycont['key']
   380             entry.insert(0, sortkey)
   384             entry.insert(0, sortkey)
   381             entry.insert(1, bibkey)
   385             entry.insert(1, bibkey)
       
   386             entry.insert(2, entryid)
   382            
   387            
   383             # add the entry to the file contents
   388             # add the entry to the file contents
   384             filecont.append(entry)
   389             filecont.append(entry)
   385 
   390 
   386         else:
   391         else:
   437     
   442     
   438     # generate output
   443     # generate output
   439     for entry in filecont:
   444     for entry in filecont:
   440         # generate output key form the bibtex key
   445         # generate output key form the bibtex key
   441         bibkey = entry[1]
   446         bibkey = entry[1]
       
   447         entryid = entry[2]
   442         if keytable[bibkey] == 1:
   448         if keytable[bibkey] == 1:
   443             outkey = bibkey
   449             outkey = bibkey
   444         else:
   450         else:
   445             outkey = bibkey + chr(97 + counttable[bibkey])
   451             outkey = bibkey + chr(97 + counttable[bibkey])
   446         counttable[bibkey] += 1
   452         counttable[bibkey] += 1
   447         
   453         
   448         # append the entry code to the output
   454         # append the entry code to the output
   449         file.append('<tr valign="top">\n' + \
   455         file.append('\\section ' + entryid + ' [' + outkey + ']')
   450                     '<td>[' + outkey + ']</td>')
   456         file.append('<div style="' + divstyle + '">')
   451         file.append('<td>')
   457         for line in entry[3:]:
   452         file.append('\\anchor ' + outkey)
       
   453         for line in entry[2:]:
       
   454             file.append(line)
   458             file.append(line)
   455         file.append('</td>\n</tr>')
   459         file.append('</div>')
   456         file.append('')
   460         file.append('')
   457 
   461 
   458     return file
   462     return file
   459 
   463 
   460 
   464 
   778     washeddata = bibtexwasher(filecont_source)
   782     washeddata = bibtexwasher(filecont_source)
   779     outdata = bibtexdecoder(washeddata)
   783     outdata = bibtexdecoder(washeddata)
   780     print '/**'
   784     print '/**'
   781     print '\page references References'
   785     print '\page references References'
   782     print
   786     print
   783     print '<table border="0" cellspacing="5px" width="100%">'
       
   784     print
       
   785     for line in outdata:
   787     for line in outdata:
   786         print line
   788         print line
   787     print '</table>'
       
   788     print
       
   789     print '*/'
   789     print '*/'
   790 
   790 
   791 
   791 
   792 # main program
   792 # main program
   793 
   793