[38342] trunk/doc-new
simon at macports.org
simon at macports.org
Wed Jul 16 06:09:18 PDT 2008
Revision: 38342
http://trac.macosforge.org/projects/macports/changeset/38342
Author: simon at macports.org
Date: 2008-07-16 06:09:17 -0700 (Wed, 16 Jul 2008)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/doc-new/Makefile
Added Paths:
-----------
trunk/doc-new/toc-for-chunked.tcl
Modified: trunk/doc-new/Makefile
===================================================================
--- trunk/doc-new/Makefile 2008-07-16 12:07:43 UTC (rev 38341)
+++ trunk/doc-new/Makefile 2008-07-16 13:09:17 UTC (rev 38342)
@@ -15,6 +15,7 @@
CP = /bin/cp
RM = /bin/rm
SED = /usr/bin/sed
+TCLSH = /usr/bin/tclsh
XSLTPROC = $(PREFIX)/bin/xsltproc
XMLLINT = $(PREFIX)/bin/xmllint
@@ -25,15 +26,17 @@
GUIDE-SRC = $(GUIDE)/xml
MAN-SRC = $(MAN)/xml
# Result directories.
-GUIDE-RESULT = $(GUIDE)/html
-MAN-RESULT = $(MAN)/man/
+GUIDE-RESULT = $(GUIDE)/html
+GUIDE-RESULT-CHUNK = $(GUIDE-RESULT)/chunked
+MAN-RESULT = $(MAN)/man/
# Man temporary directory.
MAN-TMP = $(MAN)/tmp
# Path to the docbook xsl files.
-DOCBOOK = $(PREFIX)/share/xsl/docbook-xsl
-GUIDE-XSL = $(DOCBOOK)/xhtml/profile-docbook.xsl
-MAN-XSL = $(MAN)/resources/macports.xsl
+DOCBOOK = $(PREFIX)/share/xsl/docbook-xsl
+GUIDE-XSL = $(DOCBOOK)/xhtml/profile-docbook.xsl
+GUIDE-XSL-CHUNK = $(DOCBOOK)/xhtml/chunk.xsl
+MAN-XSL = $(MAN)/resources/macports.xsl
# Docbook html stylesheet for the guide.
STYLESHEET = docbook.css
@@ -44,6 +47,8 @@
--stringparam generate.toc "book toc" \
--stringparam section.label.includes.component.label 1 \
--stringparam profile.condition "noman"
+# Additional parameters for the chunked guide.
+STRINGPARAMS-CHUNK = --stringparam chunk.section.depth 0
.PHONY: all guide man clean validate
@@ -55,7 +60,8 @@
$(MKDIR) -p $(GUIDE-RESULT)
$(CP) $(GUIDE)/resources/$(STYLESHEET) $(GUIDE-RESULT)/$(STYLESHEET)
$(CP) $(GUIDE)/resources/images/* $(GUIDE-RESULT)/
- $(XSLTPROC) --xinclude $(STRINGPARAMS) --output $(GUIDE-RESULT)/index.html \
+ $(XSLTPROC) --xinclude $(STRINGPARAMS) \
+ --output $(GUIDE-RESULT)/index.html \
$(GUIDE-XSL) $(GUIDE-SRC)/guide.xml
# Convert all sections (h1-h9) to a link so it's easy to link to them.
# If someone knows a better way to do this please change it.
@@ -63,6 +69,24 @@
's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
$(GUIDE-RESULT)/index.html
+# Generate the chunked html guide with one section per file.
+guide-chunked:
+ $(MKDIR) -p $(GUIDE-RESULT-CHUNK)
+ $(CP) $(GUIDE)/resources/$(STYLESHEET) $(GUIDE-RESULT-CHUNK)/$(STYLESHEET)
+ $(CP) $(GUIDE)/resources/images/* $(GUIDE-RESULT-CHUNK)/
+ $(XSLTPROC) --xinclude $(STRINGPARAMS) $(STRINGPARAMS-CHUNK) \
+ --output $(GUIDE-RESULT-CHUNK)/index.html \
+ $(GUIDE-XSL-CHUNK) $(GUIDE-SRC)/guide.xml
+ # Convert all sections (h1-h9) to a link so it's easy to link to them.
+ # If someone knows a better way to do this please change it.
+ $(SED) -i "" -E \
+ 's|(<h[0-9] [^>]*><a id="([^"]*)"></a>)([^<]*)(</h[0-9]>)|\1<a href="#\2">\3</a>\4|g' \
+ $(GUIDE-RESULT-CHUNK)/*.html
+ # Add the table of contents to every junked html file.
+ # If someone knows a better way to do this please change it.
+ $(TCLSH) toc-for-chunked.tcl $(GUIDE-RESULT-CHUNK)
+
+
# Generate the man pages using DocBook from the xml source in $(MAN-SRC).
# The portfile-*.xml files in $(GUIDE-SRC) are copied to $(MAN-TMP) and
# modified (section -> refsection) so they can be used as man xml source files
Added: trunk/doc-new/toc-for-chunked.tcl
===================================================================
--- trunk/doc-new/toc-for-chunked.tcl (rev 0)
+++ trunk/doc-new/toc-for-chunked.tcl 2008-07-16 13:09:17 UTC (rev 38342)
@@ -0,0 +1,20 @@
+# Adds the table of contents to every file of the chunked documentation.
+
+
+# Get the table of contents from the index.html file and create the
+# replacement string.
+set file [open "[lindex $argv 0]/index.html"]
+regexp {<div class="toc">.+?</div>} [read $file] replacement
+close $file
+set replacement "<body>$replacement<div class=\"book\">"
+
+# Add the table of contents to all other html files.
+foreach path [glob -directory [lindex $argv 0] {*[0-9][0-9].html}] {
+ set file [open $path r+]
+ set data [read $file]
+ regsub {<body>} $data $replacement data
+ regsub {</body>} $data {</div></body>} data
+ seek $file 0
+ puts $file $data
+ close $file
+}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080716/176744d1/attachment.html
More information about the macports-changes
mailing list