On Sat, 2006-04-08 at 13:05, Mike Noyes wrote:
> I placed revision 1.12 in cvs yesterday. Please take a look at it if you
> have a chance. Comments and feedback are welcome.

Everyone,
The formatting on this post should be a bit better.

*** Begin doc-build.sh ***

#! /bin/bash

# PROGRAM: 
# PURPOSE: Auto-build documentation.
# HISTORY: 2006-03-16 mhnoyes Initial programming (Mike Noyes)
# HISTORY: 2006-03-18 mhnoyes Added lockfile code (Charles Steinkuehler)
# HISTORY: 2006-03-20 mhnoyes Added error check code (Steve Parker)
#                             http://steve-parker.org/sh/exitcodes.shtml
# HISTORY: 2006-03-29 mhnoyes Added local xml catalog
# HISTORY: 2006-03-30 mhnoyes Incorporated 'set -e' and 'trap' (David Pashley)
#     http://www.davidpashley.com/articles/writing-robust-shell-scripts.html

# NOTES: XSL Customization
#   use.id.as.filename
#   chunker.output.indent
#       <xsl:attribute-set name="monospace.verbatim.properties">
#           <xsl:attribute name="wrap-option">wrap</xsl:attribute>
#           <xsl:attribute name="hyphenation-character">\</xsl:attribute>
#       </xsl:attribute-set>

# NOTES: XML
#   olink database
#   xhtml validation


#----------------------------------------
# VARIABLES
#----------------------------------------

set -e
DATE=`date '+%Y-%m-%d %T %Z'`
PROJ_DIR=/home/groups/l/le/leaf
TMP_DIR=/tmp/persistent/leaf
PSERVER="-d:pserver:[EMAIL PROTECTED]:/cvsroot/leaf"
DB_XSL="/home/groups/d/do/docbook/htdocs/release/xsl/current"
DB_XSL_CUST="/tmp/persistent/leaf/doc/docbook"
LOCKFILE=leafcron.lock
export 
XML_CATALOG_FILES="/home/groups/l/le/leaf/admin/docbook-xml-4.4/catalog.xml 
/etc/xml/catalog"
# export XML_DEBUG_CATALOG=

#----------------------------------------
# FUNCTIONS
#----------------------------------------

cleanup () {
  if [ -e "$TMP_DIR"/doc ]; then
    rm -rf "$TMP_DIR"/doc
  fi
}

check_errors () {
  if [ "${1}" -ne "0" ]; then
    echo "ERROR # ${1} : ${2}"
    cleanup
    exit ${1}
  fi
}

create_lockfile () {
  trap "rm -f $TMP_DIR/$LOCKFILE; exit" INT TERM EXIT
  lockfile -r 0 -l 72000 $TMP_DIR/$LOCKFILE || \
    check_errors $? "Lockfile creation failed."
  echo "Got lock file: $LOCKFILE"
}

export_documents () {
  cd "$TMP_DIR"
  cvs "$PSERVER" -q export -D "$DATE" -d doc doc || \
    check_errors $? "CVS export error."
  ln -s "$DB_XSL"/images doc/docbook/images
  echo "Options +Indexes
AddType 'text/html; charset=UTF-8' html" > doc/.htaccess
}

validate_documents () {
  cd "$TMP_DIR"/doc
  xmllint --noout --xinclude --postvalid --noent leaf-doc-set.xml || \
    check_errors $? "Document validation failure!"
  echo "Document validation success."
}

build_doc () {
  cd "$TMP_DIR"/doc
  xsltproc --xinclude "$DB_XSL"/xhtml/chunk.xsl leaf-doc-set.xml || \
    check_errors $? "XSLT failure!"
  echo "DocBook XML XSLT complete."
}

build_man () {
  cd "$TMP_DIR"/doc/man
  for f in *; do
    groff -t -mandoc -Thtml $f > $f.html
    groff -t -mandoc -Tps $f > $f.ps
    ps2pdf $f.ps
    rm $f.ps
  done
}

replace_old () {
  chgrp -R leaf "$TMP_DIR"/doc
  if [ -e "$PROJ_DIR"/doc ]; then
    rm -rf "$PROJ_DIR"/doc
  fi
  mv "$TMP_DIR"/doc "$PROJ_DIR"/
}


#----------------------------------------
# MAIN PROGRAM
#----------------------------------------

create_lockfile
cleanup

echo ---
umask 002
echo Exporting documents from CVS.
export_documents

echo ---
echo Validating documents.
validate_documents

echo ---
echo Converting man pages to html and pdf
build_man

echo ---
echo Building Documentation
build_doc

replace_old

rm -f $TMP_DIR/$LOCKFILE
trap - INT TERM EXIT

*** End doc-build.sh ***

-- 
Mike Noyes <mhnoyes at users.sourceforge.net>
http://sourceforge.net/users/mhnoyes/
SF.net Projects: leaf, phpwebsite, phpwebsite-comm, sitedocs



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642

_______________________________________________
leaf-devel mailing list
leaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/leaf-devel

Reply via email to