source: trunk/doc-new/toc-for-chunked.tcl @ 38342

Last change on this file since 38342 was 38342, checked in by simon@…, 12 years ago

doc-new: New target "guide-chunked" which generates a chunked version of the guide.

The table of contents is automatically added to every page after the
generation and the section links are clickable like the normal guide. All
files are created in guide/html/chunked.

The tclsh binary has to be available as a simple Tcl script is used to add the
table of contents. If you know a better way to do this please change it.

File size: 667 bytes
Line 
1# Adds the table of contents to every file of the chunked documentation.
2
3
4# Get the table of contents from the index.html file and create the
5# replacement string.
6set file [open "[lindex $argv 0]/index.html"]
7regexp {<div class="toc">.+?</div>} [read $file] replacement
8close $file
9set replacement "<body>$replacement<div class=\"book\">"
10
11# Add the table of contents to all other html files.
12foreach path [glob -directory [lindex $argv 0] {*[0-9][0-9].html}] {
13    set file [open $path r+]
14    set data [read $file]
15    regsub {<body>} $data $replacement data
16    regsub {</body>} $data {</div></body>} data
17    seek $file 0
18    puts $file $data
19    close $file
20}
Note: See TracBrowser for help on using the repository browser.