11 def sec_inc(section, lev):
12 while len(section)<lev:
25 def compare_sec(id1, id2):
29 c1=c1*max_sec_number+int(s)
30 for i in range(len(id1), max_sec_depth+1):
35 c2=c2*max_sec_number+int(s)
36 for i in range(len(id2), max_sec_depth+1):
45 for l in open("toc.txt").readlines():
47 if len(sl)==2 and len(sl[0])>0:
49 section=sec_inc(section,lev)
50 t_sec=copy.copy(section)
52 print format_sec(t_sec),t_link
53 ind[t_link]=[t_sec,'','']
55 ind[t_link][1]=prev_page
57 ind[prev_page][2]=t_link
59 toc[format_sec(t_sec)]=t_link
61 for doxfile in os.listdir('.'):
62 if doxfile[-4:]=='.dox':
63 print 'Generate ',doxfile
65 fo=open(os.path.join("gen-dox",doxfile),"w")
66 for l in open(doxfile).readlines():
67 gr = re.match(r"(^[[]PAGE[]].*[[]PAGE[]])?(^[[]SEC[]].*[[]SEC[]])?(^[[]TRAILER[]])?(^[[]TOC[]])?(.*)$", l).groups()
70 fo.write("\page %s %s%s\n"%(page,
71 format_sec(ind[page][0]),gr[4]))
74 fo.write("\section %s %s%s\n"%(sec,
75 format_sec(ind[sec][0]),gr[4]))
77 prev_page=ind[page][1]
79 prev_str= ( '<< \\ref '+prev_page+' ')
82 next_page=ind[page][2]
84 next_str= ( ' \\ref '+next_page+' >>')
87 fo.write('%s| \\ref sec_toc "Home" |%s\n'%\
90 secs = [ x for x in toc ]
91 secs.sort(compare_sec)
93 fo.write("%s - \\ref %s\n"%(' '*((len(ind[toc[num]][0]))),