8 def sec_inc(section, lev):
9 while len(section)<lev:
27 for l in open("toc.txt").readlines():
29 if len(sl)==2 and len(sl[0])>0:
31 section=sec_inc(section,lev)
32 t_sec=copy.copy(section)
34 print format_sec(t_sec),t_link
35 ind[t_link]=[t_sec,'','']
37 ind[t_link][1]=prev_page
39 ind[prev_page][2]=t_link
41 toc[format_sec(t_sec)]=t_link
43 for doxfile in os.listdir('.'):
44 if doxfile[-4:]=='.dox':
45 print 'Generate ',doxfile
47 fo=open(os.path.join("gen-dox",doxfile),"w")
48 for l in open(doxfile).readlines():
49 gr = re.match(r"(^[[]PAGE[]].*[[]PAGE[]])?(^[[]SEC[]].*[[]SEC[]])?(^[[]TRAILER[]])?(^[[]TOC[]])?(.*)$", l).groups()
52 fo.write("\page %s %s%s\n"%(page,
53 format_sec(ind[page][0]),gr[4]))
56 fo.write("\section %s %s%s\n"%(sec,
57 format_sec(ind[sec][0]),gr[4]))
59 prev_page=ind[page][1]
61 prev_str= ( '<< \\ref '+prev_page+' ')
64 next_page=ind[page][2]
66 next_str= ( ' \\ref '+next_page+' >>')
69 fo.write('%s| \\ref sec_toc "Home" |%s\n'%\
72 secs = [ x for x in toc]
75 fo.write("%s - \\ref %s\n"%(' '*((len(ind[toc[num]][0]))),