Table of Contents
Here is the source code of the scripts we use to build our documentation.
#!/bin/bash
# This script generates output for each specified format. It calls
# the processing tools: jade, jadetex, pdfjadetex, and toc2toc for
# generating QNX Helpviewer and PDF output, as well as HTML ouput
# with the DSSSL stylesheets. It calls the processing tools: osx and
# xsltproc to generate XML and then HTML and Windows HTML Help output
# with the XSL stylesheets.
# Defines a function that parses the SGML source to find the names of all
# image files used, and then copies those files from doc/i/images/ into the
# desired output directories.
Copy() {
dir=${1};
ext=${2};
onsgmls -f'/dev/null' main.sgml | grep "AFILEREF .*${ext}" | cut -c16-0 > imagenames.txt
typeset -i cnt=0
while read line
do
imarray[$cnt]=$line
((cnt = cnt + 1))
done < imagenames.txt
for I in ${imarray[@]}
do
[ -f $f ] && cp ../../i/images/${I} ${dir}
done
rm -f imagenames.txt
}
# Assigns the variable for output type: help, html, html-s, pdf, etc.
# The html-s type is HTML from SGML, using DSSSL stylesheets. This has
# now been deprecated in favor of HTML from XML, using XSL stylesheets.
type=$1; shift
# Updates doc/i/common/dates.sgml
latestdate.sh
# Generates output for each format specified.
case $type in
-help|-html-s)
# Sets up the appropriate subdirectory.
case $type in
-help) subdir=help;
;;
-html-s) subdir=html;
;;
esac
mkdir -p $subdir
# Copies in all necessary image files.
mkdir -p $subdir/stylesheet-images
Copy $subdir .gif
cp ../../i/images/ss-images/*.gif $subdir/stylesheet-images
# Reads in and assigns variables for DSSSL stylesheet and
# SGML file (usually main.sgml).
dsl=$1; shift
sgml=$1; shift
cd $subdir
# Transforms SGML to HTML. The -E 5 option limits error messages to 5.
jade -t sgml -i html -E 5 -d ../$dsl\#html ../$sgml
case $type in
-help)
# Creates a Helpviewer toc using the toc2toc script.
: > toc_index
base=`basename $sgml .sgml`
for f in book*.html;
do
b=`basename $f .html`
tidy -wrap 0 < $f > _$f.tidy 2>/dev/null
toc2toc -l3 < _$f.tidy > _$b.toc
cp ../../../i/cogent_set/$b.title $b.toc
# Makes book subdirectory & puts in toc
mkdir -p $b
rm -r -f $b/*
mv _$b.toc $b/book.toc
# Copies title page images to book subdirectory
c=`echo $b | cut -c 5-`
if [ -e $c-cover.gif ]; then
cp $c-cover.gif $b/
fi
cp Cogent_Title.gif $b/
# Works around a QNX Helpviewer bug.
sed 's/a href=\"/a href=\"..\//g' < _$f.tidy > $f 2>/dev/null
mv $f $b/
echo $b.toc >> toc_index
done
rm -f _*
# Works around a QNX Helpviewer bug.
for f in *.html;
do
fixentities $f > $f.fix && mv $f.fix $f
done
;;
-html-s)
cd ..
# Creates the index for books and/or the set.
collate-all -i html/HTML.index
;;
esac
;;
-winhelp)
mkdir -p winhelp
# Copies in all necessary image files.
mkdir -p winhelp/images/
Copy winhelp .gif
cp ../../i/images/ss-images/*.gif winhelp/images/
cp ../../config/winhelpstyle.css winhelp/
# Reads in the stylesheet, the main.sgml source file,
# the document title used in Windows, and the name of the
# html page that appears when the Help viewer starts up.
wsl=$1; shift
sgml=$1; shift
title=$1; shift
startpg=$1; shift
# Validates the SGML file. Validation is also done by osx (below), but it
# generates misleading error messages which we can't shut off without losing
# the useful ones.
onsgmls -E5 -s $sgml
# Converts SGML to XML, disregarding all error messages.
osx -wno-valid -x lower -x no-nl-in-tag $sgml > main.xml 2>/dev/null
# Writes in the DOCTYPE declaration with DTD for processing char entities
# and an ENTITY definition for xinclude.mod. used for programlistings.
sed main.xml -f ../../config/prex.sed > output1.xml
# Preprocesses the XML file for program listings, using the html-prex.xsl stylesheet.
xsltproc ../../config/html-prex.xsl output1.xml > output2.xml
# Converts XML to HTML.
xsltproc --catalogs --xinclude -o winhelp/ $wsl output2.xml #2>errors.txt
# Zips up the file for distribution.
cd winhelp
zip -r -q $title.zip *
mv $title.zip ../
cd ..
;;
-html)
mkdir -p html
# Copies in all necessary image files and the cascading stylesheet.
mkdir -p html/images/
Copy html .gif
cp ../../i/images/ss-images/*.gif html/images/
cp ../../config/xhstyle.css html/
# Reads in the stylesheet and the main.sgml source file.
xsl=$1; shift
sgml=$1; shift
# Validates the SGML file. Validation is also done by osx (below), but it
# generates misleading error messages which we can't shut off without losing
# the useful ones.
onsgmls -E5 -s $sgml
# Converts SGML to XML, disregarding all error messages.
osx -wno-valid -x lower -x no-nl-in-tag $sgml > main.xml 2>/dev/null
# Writes in the DOCTYPE declaration with DTD for processing char entities
# and an ENTITY definition for xinclude.mod. used for programlistings.
sed main.xml -f ../../config/prex.sed > output1.xml
# Preprocesses the XML file for program listings, using the html-prex.xsl stylesheet.
# Note: if there is even one incorrect fileref none of the program listings will
# get processed.
xsltproc ../../config/html-prex.xsl output1.xml > output2.xml
# Converts XML to HTML.
xsltproc --catalogs --xinclude -o html/ $xsl output2.xml #2>errors.txt
;;
-hindex)
# This is a hack that uses Jade with DSSSL to make the file HTML.index.
# We need HTML.index for collateindex.pl (called here by collate-all),
# to create indicies for PDF output, because we're still using the Jade/DSSSL
# toolchain. However, the HTML output from Jade is the old-style HTML
# output, which we don't need. So this whole operation is done in a
# temporary directory, which we delete once we have run collate-all
# on the HTML.index file. Ironically, the least intrusive way to
# maintain a single source means we have to use this same system for HTML.
# However once we are using the XSL toolchain for PDFs, we can eliminate
# this hack altogether, and use the built-in XSL indexing.
dsl=$1; shift
sgml=$1; shift
# Creates a temporary directory.
mkdir -p htmlindex
cd htmlindex
# Transforms SGML to HTML.
jade -t sgml -i html -E 5 -d ../${dsl}\#html -o junk.html ../${sgml} > /dev/null
# Creates the index.
cd ..
collate-all -i htmlindex/HTML.index
# Removes the temporary directory.
rm -r htmlindex
;;
-tex)
dsl=$1; shift
sgml=$1; shift
base=`basename $sgml .sgml`
mkdir -p tex
cd tex
# Creates TeX output, with a maximum of 5 error messages.
jade -t tex -E 5 -d ../$dsl\#print -o $base.tex ../$sgml
true
;;
-pdf)
mkdir -p pdf
tex=$1; shift
cfg=$1; shift
base=`basename $tex .tex`
Copy pdf .pdf
cd pdf
cp ../$cfg jadetex.cfg
pdfjadetex ../$tex
return=$?
if egrep '^LaTeX Warning: There were undefined references.' $base.log >/dev/null 2>&1 ;
then
pdfjadetex ../$tex 2>&1 >/dev/null
pdfjadetex ../$tex
return=$?
fi
exit $return
;;
-dvi)
mkdir -p dvi
tex=$1; shift
base=`basename $tex .tex`; shift
Copy dvi .eps
cd dvi
jadetex ../$tex
return=$?
if egrep '^LaTeX Warning: There were undefined references.' $base.log >/dev/null 2>&1 ;
then
jadetex ../$tex 2>&1 >/dev/null
jadetex ../$tex
return=$?
fi
exit $return
;;
-rtf)
dsl=$1; shift
sgml=$1; shift
mkdir -p rtf
Copy rtf .pdf
cd rtf
jade -t rtf -d ../$dsl\#print ../$sgml
;;
esac
Copyright © 1995-2004 by Cogent Real-Time Systems, Inc. All rights reserved.