# Set proper default for zeta components base path
ZETA_BASE=`pwd`"/../trunk"
BUILDDIR="build/"
# Paths and zeta components required for the website building process
WCV_PATHS=classes scripts templates
WCV_ZETA_COMPONENTS=Base Configuration ConsoleTools Database Feed Mail Template
# Evaluated build name - extract from path
BUILDNAME=$$(basename $(ZETA_BASE))
# Checks out the required external bits required to re-build the website.
#
# If a valid copy of Zeta Components is specified in the ZETA_BASE environment
# variable those libraries are used from there. They are checkout out
# otherwise.
checkout-wcv :
for SUBDIR in $(WCV_PATHS) ; \
do \
if [ ! -d "$$SUBDIR" ]; then \
svn checkout --ignore-externals "svn://web-content-viewer.org/wcv/trunk/$$SUBDIR" $$SUBDIR ; \
else \
svn update --ignore-externals $$SUBDIR ; \
fi; \
done
for COMPONENT in $(WCV_ZETA_COMPONENTS) ; \
do \
if [ ! -d "classes/ezc/$$COMPONENT/src" ]; then \
if [ -d "$(ZETA_BASE)/$$COMPONENT" ]; then \
ln -s "$(ZETA_BASE)/$$COMPONENT/src" "classes/ezc/$$COMPONENT/src" ; \
else \
svn checkout "http://svn.ez.no/svn/ezcomponents/trunk/$$COMPONENT/src" "classes/ezc/$$COMPONENT/src" ; \
fi; \
fi; \
done
# Sets up and cleans the build directory
builddir :
if [ ! -d $(BUILDDIR) ]; then \
mkdir $(BUILDDIR) ; \
else \
rm -rf "$(BUILDDIR)/*" ; \
fi; \
# Creates the API documentation.
#
# Requires an installation of PHPDocumentor and 2.5GB of free memory. To
# install PHPDocumentor use:
# pear install phpDocumentor
#
# The release is specified by the ZETA_BASE environment variable and defaults
# to trunk.
phpdoc : builddir
echo $(BUILDNAME)
env php -d "memory_limit=2500M" `which phpdoc` \
--directory $(ZETA_BASE) \
--templatebase "phpdoc/" \
--target "$(BUILDDIR)/phpdoc/$(BUILDNAME)/phpdoc" \
--ignore "autoload/,*autoload.php,tests/,docs/,design/" \
--hidden false \
--undocumentedelements off \
--title "Apache Zeta Components Manual" \
--parseprivate off \
--defaultpackagename "NoPackageName" \
--defaultcategoryname "NoCategoryName" \
--output "HTML:Arbit:arbit" \
--sourcecode off \
--javadocdesc off \
--pear off
for FILE in $$(find $(BUILDDIR)/phpdoc/$(BUILDNAME)/phpdoc/ -name 'classtrees_*.html' -or -name 'elementindex_*.html'); \
do \
TARGET=$$(echo $$FILE | sed -e 's/\(classtrees\|elementindex\)_\([A-Za-z]*\)\.html/\2\/\1.html/') ; \
COMPONENT=$$(basename $$FILE .html | sed -e 's/\(classtrees\|elementindex\)_//') ; \
mv "$$FILE" "$$TARGET" ; \
sed -i -e "s/$$COMPONENT\///g" "$$TARGET" ; \
done
cd "$(BUILDDIR)/phpdoc/$(BUILDNAME)" && tar -cjf "$(BUILDNAME).tar.bz2" "phpdoc/"
cd ../
# rm -rf "$(BUILDNAME)"
cd ../../
if [ ! -d "content/documentation/$(BUILDNAME)" ]; then \
mkdir -p "content/documentation/$(BUILDNAME)" ; \
fi;
cp "$(BUILDDIR)/phpdoc/$(BUILDNAME)/$(BUILDNAME).tar.bz2" "content/documentation/$(BUILDNAME)/phpdoc.tar.bz2"
rm -rf "$(BUILDDIR)/phpdoc/$(BUILDNAME)"
# Copies tutorials for a given release to the website directory.
#
# The release is specified by the ZETA_BASE environment variable and defaults
# to trunk.
tutorials :
for DOCS in $$(find $(ZETA_BASE) -name 'docs' -type d | grep -v tests) ; \
do \
LOCAL_PATH=$$(echo "$$DOCS" | sed -e "s#^$(ZETA_BASE)/\?##") ; \
COMPONENT=$$(echo "$$LOCAL_PATH" | sed -e "s#/.*\$$##") ; \
TARGET="content/documentation/$(BUILDNAME)/$$COMPONENT/" ; \
if [ ! -d "$$TARGET" ]; then \
mkdir -p "$$TARGET" ; \
fi; \
cp -r "$$DOCS/"* "$$TARGET" ; \
find $$TARGET -name ".svn" -print0 | xargs -0 -n 1 rm -rf ; \
done
echo "Generating index files…"
for COMPONENT in $$(find "content/documentation/$(BUILDNAME)/" -mindepth 1 -maxdepth 1 -type d | grep -v "\\.svn" | grep -v design) ; \
do \
INDEX_FILE="$$COMPONENT/.index.xml" ; \
echo '' > $$INDEX_FILE ; \
echo '' >> $$INDEX_FILE ; \
if [ -f "$$COMPONENT/tutorial.txt" ]; then \
echo ' Tutorialtutorial.txt' >> $$INDEX_FILE ; \
fi; \
echo ' APIphpdoc/' >> $$INDEX_FILE ; \
for FILE in $$(find "$$COMPONENT" -mindepth 1 -maxdepth 1 -name '*.txt' | grep -v tutorial) ; \
do \
LOCALFILENAME=`basename "$$FILE"` ; \
NAME=$$(basename $$FILE .txt | perl -ane ' foreach $$word ( @F ) { print ucfirst($$word)." "; } print "\n" ; ') ; \
echo " $$NAME$$LOCALFILENAME" >> $$INDEX_FILE ; \
done ; \
for FILE in $$(find "$$COMPONENT" -mindepth 1 -maxdepth 1 -type d | grep -v "\\.svn" | grep -v design | grep -v phpdoc | grep -v tutorial | grep -v functions) ; \
do \
LOCALFILENAME=`basename "$$FILE"` ; \
echo " $$LOCALFILENAME$$LOCALFILENAME/" >> $$INDEX_FILE ; \
done ; \
echo '' >> $$INDEX_FILE ; \
done
# Extract API documentation from archive and copy it to teh correct location in
# the content tree.
extract-phpdoc :
ARCHIVE="content/documentation/$(BUILDNAME)/phpdoc.tar.bz2" ; \
tar xjf "$$ARCHIVE" -C $$(dirname "$$ARCHIVE") ; \
DOC_PATH="content/documentation/$(BUILDNAME)/phpdoc/" ; \
for COMPONENT in $$(find "content/documentation/$(BUILDNAME)/" -mindepth 1 -maxdepth 1 -type d | grep -v "\\.svn" | grep -v phpdoc | grep -v design | grep -v Framework | sort) ; \
do \
NAME=$$(basename "$$COMPONENT") ; \
echo "Copy API docs for $$NAME" ; \
if [ -d "$$COMPONENT/phpdoc" ]; then \
rm -rf "$$COMPONENT/phpdoc/*" ; \
else \
mkdir -p "$$COMPONENT/phpdoc" ; \
fi ; \
cp "content/documentation/$(BUILDNAME)/phpdoc/$$NAME/"* "$$COMPONENT/phpdoc/" ; \
sed -i -e "s#\.\./$$NAME/##g" "$$COMPONENT/phpdoc/"*.html ; \
sed -i -e "s#\"\(\.\./\)\?\([a-zA-Z]*\)/#\"/zetacomponents/documentation/$(BUILDNAME)/\2/phpdoc/#g" "$$COMPONENT/phpdoc/"*.html ; \
INDEX_FILE="$$COMPONENT/phpdoc/.index.xml" ; \
echo '' > $$INDEX_FILE ; \
echo '' >> $$INDEX_FILE ; \
echo ' Class treeclasstrees.html' >> $$INDEX_FILE ; \
for FILE in $$(find "$$COMPONENT/phpdoc/" -name "*.html" | grep -v classtrees) ; \
do \
NAME=$$(basename $$FILE) ; \
echo " $$NAME$$NAME" >> $$INDEX_FILE ; \
done ; \
echo '' >> $$INDEX_FILE ; \
done ; \
rm -rf "content/documentation/$(BUILDNAME)/phpdoc"
# Build all docs for the release specified by the environment variable
# ZETA_BASE
docs : tutorials extract-phpdoc
INDEX_FILE="content/documentation/$(BUILDNAME)/.index.xml" ; \
echo '' > $$INDEX_FILE ; \
echo '' >> $$INDEX_FILE ; \
echo ' Overviewoverview.txt' >> $$INDEX_FILE ; \
for DIR in $$(find "content/documentation/$(BUILDNAME)/" -mindepth 1 -maxdepth 1 -type d | grep -v "\\.svn" | grep -v phpdoc | grep -v design | sort) ; \
do \
NAME=`basename "$$DIR"` ; \
echo " $$NAME$$NAME/" >> $$INDEX_FILE ; \
done ; \
echo '' >> $$INDEX_FILE
OVERVIEW="content/documentation/$(BUILDNAME)/overview.txt" ; \
cat content/documentation/teaser.txt > "$$OVERVIEW" ; \
for DIR in $$(find "content/documentation/$(BUILDNAME)/" -mindepth 1 -maxdepth 1 -type d | grep -v "\\.svn" | grep -v phpdoc | grep -v design | sort) ; \
do \
NAME=`basename "$$DIR"` ; \
echo "- $${NAME}__" >> $$OVERVIEW ; \
done ; \
echo '' >> $$OVERVIEW ; \
for DIR in $$(find "content/documentation/$(BUILDNAME)/" -mindepth 1 -maxdepth 1 -type d | grep -v "\\.svn" | grep -v phpdoc | grep -v design | sort) ; \
do \
NAME=`basename "$$DIR"` ; \
echo "__ /zetacomponents/documentation/$(BUILDNAME)/$$NAME/tutorial.html" >> $$OVERVIEW ; \
done
# Build the website
#
# Requires about 250MB of memory.
website : checkout-wcv extract-phpdoc
env php scripts/updateCache.php
env php var/scripts/highlight_source.php
make revert-empty
# Reverts all files without real changes
#
# Regenerating the website may cause files to appear changed, which don't have
# real changes. Especially the phpDoc files change their creation data and
# therefore the HTML meta data. These changes are automatically reverted using
# this script, so that you don't commit such "empty" changes.
revert-empty:
REVERT_FILES=""; \
echo "Scanning for files to revert …"; \
for FILE in `svn st htdocs/ | grep '^M' | awk '{ print $$2; }'`; \
do \
if [ "`svn diff --diff-cmd 'diff' -x -U0 $$FILE | sed '1,4d' | grep -v -f 'var/scripts/htdocs_ignore.grep'`" = "" ]; \
then \
REVERT_FILES="$$REVERT_FILES '$$FILE'"; \
fi; \
done; \
if [ "$$REVERT_FILES" = "" ]; \
then \
echo "No files to be reverted."; \
else \
echo "Reverting files …"; \
echo "$$REVERT_FILES" | xargs svn revert; \
fi; \