alpar@10: #! /usr/bin/env python alpar@10: alpar@10: import sys alpar@10: import os alpar@10: import copy alpar@10: import re alpar@10: alpar@10: def sec_inc(section, lev): alpar@10: while len(section)0: alpar@10: lev=len(sl[0]) alpar@10: section=sec_inc(section,lev) alpar@10: t_sec=copy.copy(section) alpar@10: t_link=sl[1]; alpar@10: print format_sec(t_sec),t_link alpar@10: ind[t_link]=[t_sec,'',''] alpar@10: if lev==1: alpar@10: ind[t_link][1]=prev_page alpar@10: if prev_page: alpar@10: ind[prev_page][2]=t_link alpar@10: prev_page=t_link alpar@10: toc[format_sec(t_sec)]=t_link alpar@10: alpar@10: for doxfile in os.listdir('.'): alpar@10: if doxfile[-4:]=='.dox': alpar@10: print 'Generate ',doxfile alpar@10: page='' alpar@10: fo=open(os.path.join("gen-dox",doxfile),"w") alpar@10: for l in open(doxfile).readlines(): alpar@10: gr = re.match(r"(^[[]PAGE[]].*[[]PAGE[]])?(^[[]SEC[]].*[[]SEC[]])?(^[[]TRAILER[]])?(^[[]TOC[]])?(.*)$", l).groups() alpar@10: if gr[0]: alpar@10: page=gr[0][6:-6] alpar@10: fo.write("\page %s %s%s\n"%(page, alpar@10: format_sec(ind[page][0]),gr[4])) alpar@10: elif gr[1]: alpar@10: sec=gr[1][5:-5] alpar@10: fo.write("\section %s %s%s\n"%(sec, alpar@10: format_sec(ind[sec][0]),gr[4])) alpar@10: elif gr[2]: alpar@10: prev_page=ind[page][1] alpar@13: if prev_page: alpar@14: prev_str= ( '<< \\ref '+prev_page+' ') alpar@13: else: alpar@13: prev_str='' alpar@10: next_page=ind[page][2] alpar@13: if next_page: alpar@14: next_str= ( ' \\ref '+next_page+' >>') alpar@13: else: alpar@13: next_str='' kpeter@26: fo.write('%s| \\ref sec_toc "Home" |%s\n'%\ alpar@10: (prev_str,next_str)) alpar@10: elif gr[3]: alpar@10: secs = [ x for x in toc] alpar@10: secs.sort() alpar@10: for num in secs: alpar@15: fo.write("%s - \\ref %s\n"%(' '*((len(ind[toc[num]][0]))), alpar@15: toc[num])) alpar@10: else: alpar@10: fo.write(gr[4]+'\n') alpar@10: fo.close()