Last change
on this file since 18:a291609dad52 was
17:0b3b26cd1cea,
checked in by Alpar Juttner <alpar@…>, 16 years ago
|
Better build system
- configure script added
- demo/*.cc are now compiled (the executables are in demo/build)
- version number appears in the doc and automatically updates
- the cross reference to the lemon doc can be relocated (e.g. to a local
copy of the doc)
- some repo reorganization has taken place
- better .hgignore
|
|
File size:
2.3 KB
|
Rev | Line | |
---|
[10] | 1 | #! /usr/bin/env python |
---|
| 2 | |
---|
| 3 | import sys |
---|
| 4 | import os |
---|
| 5 | import copy |
---|
| 6 | import re |
---|
| 7 | |
---|
| 8 | def sec_inc(section, lev): |
---|
| 9 | while len(section)<lev: |
---|
| 10 | section.append(0) |
---|
| 11 | section[lev-1]+=1 |
---|
| 12 | section=section[:lev] |
---|
| 13 | return section |
---|
| 14 | |
---|
| 15 | def format_sec(sec): |
---|
| 16 | s="" |
---|
| 17 | for i in sec: |
---|
| 18 | s+=str(i)+'.' |
---|
[15] | 19 | s=s[:-1] |
---|
[10] | 20 | return s |
---|
| 21 | |
---|
| 22 | section = []; |
---|
| 23 | toc={} |
---|
| 24 | ind={} |
---|
| 25 | |
---|
| 26 | prev_page='' |
---|
| 27 | for l in open("toc.txt").readlines(): |
---|
| 28 | sl = l.split() |
---|
| 29 | if len(sl)==2 and len(sl[0])>0: |
---|
| 30 | lev=len(sl[0]) |
---|
| 31 | section=sec_inc(section,lev) |
---|
| 32 | t_sec=copy.copy(section) |
---|
| 33 | t_link=sl[1]; |
---|
| 34 | print format_sec(t_sec),t_link |
---|
| 35 | ind[t_link]=[t_sec,'',''] |
---|
| 36 | if lev==1: |
---|
| 37 | ind[t_link][1]=prev_page |
---|
| 38 | if prev_page: |
---|
| 39 | ind[prev_page][2]=t_link |
---|
| 40 | prev_page=t_link |
---|
| 41 | toc[format_sec(t_sec)]=t_link |
---|
| 42 | |
---|
| 43 | for doxfile in os.listdir('.'): |
---|
| 44 | if doxfile[-4:]=='.dox': |
---|
| 45 | print 'Generate ',doxfile |
---|
| 46 | page='' |
---|
| 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() |
---|
| 50 | if gr[0]: |
---|
| 51 | page=gr[0][6:-6] |
---|
| 52 | fo.write("\page %s %s%s\n"%(page, |
---|
| 53 | format_sec(ind[page][0]),gr[4])) |
---|
| 54 | elif gr[1]: |
---|
| 55 | sec=gr[1][5:-5] |
---|
| 56 | fo.write("\section %s %s%s\n"%(sec, |
---|
| 57 | format_sec(ind[sec][0]),gr[4])) |
---|
| 58 | elif gr[2]: |
---|
| 59 | prev_page=ind[page][1] |
---|
[13] | 60 | if prev_page: |
---|
[14] | 61 | prev_str= ( '<< \\ref '+prev_page+' ') |
---|
[13] | 62 | else: |
---|
| 63 | prev_str='' |
---|
[10] | 64 | next_page=ind[page][2] |
---|
[13] | 65 | if next_page: |
---|
[14] | 66 | next_str= ( ' \\ref '+next_page+' >>') |
---|
[13] | 67 | else: |
---|
| 68 | next_str='' |
---|
[14] | 69 | fo.write('%s| \\ref toc "Home" |%s\n'%\ |
---|
[10] | 70 | (prev_str,next_str)) |
---|
| 71 | elif gr[3]: |
---|
| 72 | secs = [ x for x in toc] |
---|
| 73 | secs.sort() |
---|
| 74 | for num in secs: |
---|
[15] | 75 | fo.write("%s - \\ref %s\n"%(' '*((len(ind[toc[num]][0]))), |
---|
| 76 | toc[num])) |
---|
[10] | 77 | else: |
---|
| 78 | fo.write(gr[4]+'\n') |
---|
| 79 | fo.close() |
---|
Note: See
TracBrowser
for help on using the repository browser.