#!/bin/bash #mk_pydocs.sh # #This script creates new or updated browsable documentation from the Python #docstrings in CryptoNAS. It must be run from the "trunk" directory. #In addition, SVN must know about the "trunk/src" directory (i.e #"trunk/src" or one of its parents must have been checked out previously). # #epydoc 3.0.1 or later is required for proper operation. set -e PYTHONPATH="src" ##Define variables which name programs EPYDOC="epydoc" RM="rm" MV="mv" MKDIR="mkdir" LFTP="/usr/bin/lftp" ##must provide complete pathname here TAR="tar" SVN="svn" ##Output directory (note that this appears to require an absolute path name) DOCTREE="${HOME}/src/pydoc/" TAR_STRIP_DIRS="4" ##Location of a svn tree that it's ok to update and revert SVN_SANDBOX="${HOME}/src/trunk" ##Top of the directory tree for Python libraries being tested export PYTHONPATH="${HOME}/src/trunk/src" PLUGINPATH="${HOME}/src/trunk/plugins" ##Capture the svn revision number corresponding to the pydoc docs REVISION="`svn info src | grep -E 'Last Changed Rev: [[:digit:]]' | grep -o -E '[[:digit:]]+'`" ##Version string for html doc output DOC_VSTRING="cnas-html_r${REVISION}" ##Name of temporary directory used for epydoc output TEMP_HTML_PATH="${DOCTREE}cnas-html.tmp" ##Final name of epydoc output directory HTML_PATH="${DOCTREE}html" ## Assume we are being run from the "trunk" directory ##Type(s) of documentation to create PYDOC_ACTIONS="--html" PYDOC_PROJNAME=CryptoNAS PYDOC_URL="http://devel.cryptobox.org/" PYDOC_OPTIONS="--show-sourcecode --verbose " # --include-log ##Make sure sandbox is up-to-date ${SVN} revert ${SVN_SANDBOX} ${SVN} update ${SVN_SANDBOX} #TODO: I bet there's a way to do this more cleanly using find -exec '{}' or something ## (or maybe not. Bash isn't Python.) ##Find source files to document. Look in src and plugin directories, ##but skip unittests and root_action files because they are not unique. SOURCES="`find ${PYTHONPATH} -name '*.py'` \ `find ${PLUGINPATH} -name '*.py' ! -name '*unittests.py' ! -name '*root_action.py'`" ##Make a temporary directory in the doc tree $MKDIR -p "${TEMP_HTML_PATH}" ##Generate pydocs in the temp directory $EPYDOC $PYDOC_ACTIONS $PYDOC_OPTIONS --output=${TEMP_HTML_PATH} ${SOURCES} ##Remove the old docs directory $RM -rf "${HTML_PATH}" ##Rename the new temp doc directory $MV "${TEMP_HTML_PATH}" "${HTML_PATH}" $RM -f ${DOCTREE}*.tgz ##Create compressed archive of newly-created docs #use --strip-components to strip leading directories from paths in tar $TAR --strip-components ${TAR_STRIP_DIRS} -czf "${DOCTREE}/${DOC_VSTRING}.tgz" "${HTML_PATH}" #LFTP_OPTIONS="" LFTP_HOST="sftp://systemausfall.org" LFTP_DIR="/home/frisco/public_html/pydoc" ##If LFTP is enabled, perform upload to server if [ -x ${LFTP} ]; then ${LFTP} -p 2222 -u frisco, ${LFTP_OPTIONS} -e "mirror -R --delete ${DOCTREE} ${LFTP_DIR}" ${LFTP_HOST} fi