2008-05-02 22:19:38 +08:00
|
|
|
#!/bin/bash
|
2015-09-27 10:24:51 +08:00
|
|
|
. bash_helper_functions
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
report_failure ()
|
|
|
|
{
|
|
|
|
echo " **** failed to complete **** "
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2013-05-27 06:46:38 +08:00
|
|
|
htmlify_python_file ()
|
|
|
|
{
|
|
|
|
pygmentize -f html -O full,style=vs $1 > $1.html
|
|
|
|
}
|
|
|
|
|
2013-08-15 09:23:16 +08:00
|
|
|
build_python_interface ()
|
|
|
|
{
|
|
|
|
pushd ../python_examples
|
|
|
|
mkdir build
|
|
|
|
cd build || report_failure
|
|
|
|
cmake ../../tools/python || report_failure
|
|
|
|
make -j4 install || report_failure
|
2013-08-17 22:35:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
# Check if we should run all the python examples to make sure they
|
|
|
|
# work without generating an error.
|
|
|
|
if [ $1 == "test-python" ]
|
|
|
|
then
|
|
|
|
cd ..
|
|
|
|
FILES=`ls *.py`
|
|
|
|
for f in $FILES
|
|
|
|
do
|
2015-06-04 08:15:06 +08:00
|
|
|
python $f > /dev/null < /dev/null || report_failure
|
2013-08-17 22:35:35 +08:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2013-08-15 09:23:16 +08:00
|
|
|
popd
|
|
|
|
}
|
|
|
|
|
2014-01-12 03:38:23 +08:00
|
|
|
add_links_between_example_programs()
|
|
|
|
{
|
2014-02-24 07:06:19 +08:00
|
|
|
EXT=$3
|
2014-01-12 03:38:23 +08:00
|
|
|
# Get the list of example program filenames
|
|
|
|
pushd $1 > /dev/null
|
2014-02-24 07:06:19 +08:00
|
|
|
FILES=`ls *.$EXT`
|
2014-01-12 03:38:23 +08:00
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
# Now run sed on all the htmlified example programs to add the links between them.
|
|
|
|
for f in $FILES
|
|
|
|
do
|
|
|
|
#escape the . in the filename
|
|
|
|
escaped_name=`echo $f | sed -e 's/\./\\\./g'`
|
|
|
|
pushd $1 > /dev/null
|
|
|
|
# get a list of all the html example files that contain the name
|
2014-02-24 07:06:19 +08:00
|
|
|
matching_html_files=`grep -e "\b$escaped_name\b" -l *.$EXT | sed -e "s/\.$EXT\b/.$EXT.html/g"`
|
2014-01-12 03:38:23 +08:00
|
|
|
popd > /dev/null
|
|
|
|
|
|
|
|
# now actually run sed to add the links
|
|
|
|
pushd $2 > /dev/null
|
|
|
|
if [ -n "$matching_html_files" ]
|
|
|
|
then
|
|
|
|
sed -i -e "s/\b$escaped_name\b/<a href=\"$escaped_name.html\">$escaped_name<\/a>/g" $matching_html_files
|
|
|
|
fi
|
|
|
|
popd > /dev/null
|
|
|
|
done
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2008-05-02 22:19:38 +08:00
|
|
|
htmlify_cmake ()
|
|
|
|
{
|
|
|
|
echo "<html><head><title>" > $1.html;
|
|
|
|
echo $1 >> $1.html;
|
|
|
|
echo "</title></head><body bgcolor='white'><pre>" >> $1.html;
|
|
|
|
|
2015-09-27 10:24:51 +08:00
|
|
|
# line 1: make comments green
|
|
|
|
# line 2: add links into the add_subdirectory directives
|
|
|
|
# line 3: make literal quotes red
|
|
|
|
# line 4: make the directives show up blue
|
|
|
|
# line 5: make variable names show up purple
|
2008-05-02 22:19:38 +08:00
|
|
|
sed -e "s/^\([ ]*#.*\)/<font color='#009900'>\1<\/font>/" \
|
|
|
|
-e "s/add_subdirectory\([ ]*\)(\([ ]*\)\([^ ]*\)\([ ]*\)\([^ )]*\)/add_subdirectory\1(\2\3\4<a href='\3\/CMakeLists.txt.html'>\5<\/a>/" \
|
|
|
|
-e "s/\"\([^\"]*\)\"/\"<font color='#CC0000'>\1<\/font>\"/g" \
|
|
|
|
-e "s/^\([ ]*[^( ]*[ ]*\)(/<font color='blue'>\1<\/font>(/" \
|
|
|
|
-e "s/{\([^}]*\)}/\{<font color='#BB00BB'>\1<\/font>}/g" \
|
|
|
|
$1 >> $1.html;
|
|
|
|
|
2013-05-27 06:46:38 +08:00
|
|
|
echo "</pre></body></html>" >> $1.html;
|
|
|
|
}
|
|
|
|
|
|
|
|
htmlify_python()
|
|
|
|
{
|
|
|
|
FILES=`\ls $1/*.py`
|
|
|
|
for i in $FILES
|
|
|
|
do
|
|
|
|
htmlify_python_file ${i}
|
|
|
|
rm ${i}
|
|
|
|
done
|
2008-05-02 22:19:38 +08:00
|
|
|
}
|
|
|
|
|
2011-05-22 23:05:12 +08:00
|
|
|
|
2008-05-02 22:19:38 +08:00
|
|
|
makedocs ()
|
|
|
|
{
|
|
|
|
|
|
|
|
REVNUM_FILE=.logger_revnum
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-27 10:24:51 +08:00
|
|
|
# figure out the short number that identifies this particular changeset
|
2011-05-16 05:46:16 +08:00
|
|
|
get_short_revision_number `cat $REVNUM_FILE`
|
|
|
|
LOGGER_REVNUM=$RESULT
|
|
|
|
|
2008-05-02 22:19:38 +08:00
|
|
|
XSLT_OPTIONS="--nodtdattr --nonet --novalid"
|
2011-05-22 23:05:12 +08:00
|
|
|
DATE_TODAY=`date --date= "+%b %d, %Y"`;
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-09-27 10:24:51 +08:00
|
|
|
# The revision number we are currently at
|
2011-05-16 05:46:16 +08:00
|
|
|
CHANGESET_ID=`hg id -i | sed -e 's/\+//'`
|
|
|
|
get_short_revision_number $CHANGESET_ID
|
|
|
|
REVISION=$RESULT
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
|
2011-09-21 06:27:47 +08:00
|
|
|
if [ "$1" = "makerel" ]
|
|
|
|
then
|
|
|
|
RELEASE=${MAJOR_NUM}.${MINOR_NUM}
|
|
|
|
else
|
2015-09-27 10:24:51 +08:00
|
|
|
RELEASE=${MAJOR_NUM}.${MINOR_NUM}.${PATCH_NUM}
|
2011-09-21 06:27:47 +08:00
|
|
|
fi;
|
2008-05-02 22:19:38 +08:00
|
|
|
|
2015-09-27 10:24:51 +08:00
|
|
|
# get XML versions of the change logs
|
2011-05-16 05:46:16 +08:00
|
|
|
BASE_LOGGER_REVNUM=`echo $LOGGER_REVNUM - 1000 | bc`
|
2011-05-16 06:03:05 +08:00
|
|
|
NEXT_LOGGER_REVNUM=`echo $LOGGER_REVNUM + 1 | bc`
|
|
|
|
echo Getting the mercurial change logs for revisions $NEXT_LOGGER_REVNUM:$REVISION
|
2015-02-04 07:21:14 +08:00
|
|
|
hg log -v ../dlib ../examples ../tools ../python_examples --style=xml -r$NEXT_LOGGER_REVNUM:$REVISION > docs/log.txt || report_failure
|
2011-05-16 05:46:16 +08:00
|
|
|
echo Getting the mercurial change logs for revisions $BASE_LOGGER_REVNUM:$LOGGER_REVNUM
|
2015-02-04 07:21:14 +08:00
|
|
|
hg log -v ../dlib ../examples ../tools ../python_examples --style=xml -r$BASE_LOGGER_REVNUM:$LOGGER_REVNUM > docs/old_log.txt || report_failure
|
2008-05-02 22:19:38 +08:00
|
|
|
|
2015-09-27 10:24:51 +08:00
|
|
|
# grab a clean copy of the repository
|
2011-05-16 05:46:16 +08:00
|
|
|
rm -rf docs/cache
|
2013-05-27 06:46:38 +08:00
|
|
|
rm -rf docs/web
|
|
|
|
rm -rf docs/chm/docs
|
2015-09-27 10:24:51 +08:00
|
|
|
hg archive docs/cache || report_failure
|
|
|
|
# Don't need the docs folder in the cache, moreover, deleting it here avoids letting the makerel script include it in the dlib tar balls.
|
|
|
|
rm -rf docs/cache/docs
|
2008-05-02 22:19:38 +08:00
|
|
|
|
2010-03-08 04:53:51 +08:00
|
|
|
echo "#ifndef DLIB_REVISION_H" > docs/cache/dlib/revision.h
|
|
|
|
echo "// Version: " $RELEASE >> docs/cache/dlib/revision.h
|
|
|
|
echo "// Date: " `date` >> docs/cache/dlib/revision.h
|
2011-05-16 05:46:16 +08:00
|
|
|
echo "// Mercurial Revision ID: " $CHANGESET_ID >> docs/cache/dlib/revision.h
|
|
|
|
echo "#define DLIB_MAJOR_VERSION " $MAJOR_NUM >> docs/cache/dlib/revision.h
|
|
|
|
echo "#define DLIB_MINOR_VERSION " $MINOR_NUM >> docs/cache/dlib/revision.h
|
2015-09-27 10:24:51 +08:00
|
|
|
echo "#define DLIB_PATCH_VERSION " $PATCH_NUM >> docs/cache/dlib/revision.h
|
2010-03-08 04:53:51 +08:00
|
|
|
echo "#endif" >> docs/cache/dlib/revision.h
|
|
|
|
|
|
|
|
|
2011-05-16 05:46:16 +08:00
|
|
|
rm -rf docs/web
|
|
|
|
rm -rf docs/chm/docs
|
|
|
|
mkdir docs/web
|
|
|
|
mkdir docs/chm/docs
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
echo Creating HTML version of the source
|
|
|
|
htmlify --title "dlib C++ Library - " -i docs/cache -o htmltemp.$$
|
2014-02-24 07:06:19 +08:00
|
|
|
add_links_between_example_programs docs/cache/examples htmltemp.$$/examples cpp
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
echo Copying files around...
|
|
|
|
cp -r htmltemp.$$/dlib docs/web
|
|
|
|
cp -r htmltemp.$$/dlib docs/chm/docs
|
|
|
|
cp -r htmltemp.$$/examples/* docs/web
|
|
|
|
cp -r htmltemp.$$/examples/* docs/chm/docs
|
|
|
|
rm -rf htmltemp.$$
|
|
|
|
|
2013-07-06 02:56:51 +08:00
|
|
|
# Create python docs. If we are making a release then stop immediately if
|
|
|
|
# the python docs can't be created (this happens if the .so file isn't compiled)
|
|
|
|
if [ "$1" = "makerel" ]
|
2013-08-12 09:48:18 +08:00
|
|
|
then
|
2013-08-17 22:35:35 +08:00
|
|
|
build_python_interface test-python
|
2013-07-06 02:56:51 +08:00
|
|
|
sphinx-build -b html docs/python sphinx.$$ || report_failure
|
|
|
|
else
|
2013-08-15 09:23:16 +08:00
|
|
|
if [ "$1" != "fast" ]
|
|
|
|
then
|
2013-10-07 09:36:59 +08:00
|
|
|
build_python_interface no-test-python
|
2013-08-15 09:23:16 +08:00
|
|
|
fi;
|
2013-07-06 02:56:51 +08:00
|
|
|
sphinx-build -b html docs/python sphinx.$$
|
|
|
|
fi;
|
|
|
|
|
|
|
|
cp -r sphinx.$$ docs/web/python
|
|
|
|
mv sphinx.$$ docs/chm/docs/python
|
|
|
|
|
2008-05-02 22:19:38 +08:00
|
|
|
cp docs/cache/dlib/test/makefile docs/web/dlib/test
|
|
|
|
cp docs/cache/dlib/test/makefile docs/chm/docs/dlib/test
|
|
|
|
|
|
|
|
cp docs/cache/dlib/test/CMakeLists.txt docs/web/dlib/test
|
|
|
|
cp docs/cache/dlib/test/CMakeLists.txt docs/chm/docs/dlib/test
|
|
|
|
cp docs/cache/dlib/CMakeLists.txt docs/web/dlib
|
|
|
|
cp docs/cache/dlib/CMakeLists.txt docs/chm/docs/dlib
|
|
|
|
mkdir docs/web/examples || report_failure
|
|
|
|
cp docs/cache/examples/CMakeLists.txt docs/web/examples
|
|
|
|
mkdir docs/chm/docs/examples || report_failure
|
|
|
|
cp docs/cache/examples/CMakeLists.txt docs/chm/docs/examples
|
2013-05-28 01:59:40 +08:00
|
|
|
cp docs/cache/python_examples/*.py docs/chm/docs/
|
|
|
|
cp docs/cache/python_examples/*.py docs/web/
|
|
|
|
|
|
|
|
htmlify_python docs/chm/docs/
|
|
|
|
htmlify_python docs/web/
|
2014-02-24 07:06:19 +08:00
|
|
|
add_links_between_example_programs docs/cache/python_examples docs/chm/docs py
|
|
|
|
add_links_between_example_programs docs/cache/python_examples docs/web py
|
2013-05-27 06:46:38 +08:00
|
|
|
|
2008-05-02 22:19:38 +08:00
|
|
|
cp docs/*.gif docs/web
|
|
|
|
cp docs/*.gif docs/chm/docs
|
2013-06-03 07:39:59 +08:00
|
|
|
cp docs/ml_guide.svg docs/web
|
|
|
|
cp docs/ml_guide.svg docs/chm/docs
|
2012-05-21 00:03:52 +08:00
|
|
|
cp -r docs/guipics docs/web
|
|
|
|
cp -r docs/guipics docs/chm/docs
|
2008-05-02 22:19:38 +08:00
|
|
|
cp docs/*.html docs/web
|
|
|
|
cp docs/*.html docs/chm/docs
|
2015-09-13 00:56:33 +08:00
|
|
|
cp docs/*.css docs/web
|
|
|
|
cp docs/*.css docs/chm/docs
|
|
|
|
cp docs/*.js docs/web
|
|
|
|
cp docs/*.js docs/chm/docs
|
2008-05-02 22:19:38 +08:00
|
|
|
cp docs/*.png docs/web
|
2016-10-10 01:15:15 +08:00
|
|
|
cp docs/*.jpg docs/web
|
2013-01-02 07:20:10 +08:00
|
|
|
cp docs/*.ico docs/web
|
2008-05-02 22:19:38 +08:00
|
|
|
cp docs/*.png docs/chm/docs
|
2016-10-10 01:15:15 +08:00
|
|
|
cp docs/*.jpg docs/chm/docs
|
2013-01-02 07:20:10 +08:00
|
|
|
cp docs/*.ico docs/chm/docs
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
cd docs/chm/docs || report_failure
|
|
|
|
htmlify_cmake dlib/CMakeLists.txt;
|
|
|
|
htmlify_cmake examples/CMakeLists.txt;
|
|
|
|
htmlify_cmake dlib/test/CMakeLists.txt;
|
|
|
|
cd ../../.. || report_failure
|
|
|
|
cd docs/web || report_failure
|
|
|
|
htmlify_cmake dlib/CMakeLists.txt;
|
|
|
|
htmlify_cmake examples/CMakeLists.txt;
|
|
|
|
htmlify_cmake dlib/test/CMakeLists.txt;
|
|
|
|
cd ../.. || report_failure
|
|
|
|
|
|
|
|
find docs/web docs/chm -name "CMakeLists.txt" | xargs rm
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-05-22 23:05:12 +08:00
|
|
|
# generate the HTML docs
|
|
|
|
echo Generate HTML docs from XML and XSLT style sheet
|
|
|
|
FILES=`\ls docs/*.xml | grep -v main_menu.xml`
|
|
|
|
for i in $FILES
|
|
|
|
do
|
2008-05-02 22:19:38 +08:00
|
|
|
|
2011-05-22 23:05:12 +08:00
|
|
|
# The last modified date for these files should always be the release date (regardless of when the actual xml files were modified).
|
2011-05-22 23:33:55 +08:00
|
|
|
if [ "${i}" = "docs/release_notes.xml" -o ${i} = "docs/old_release_notes.xml" \
|
2011-05-22 23:26:28 +08:00
|
|
|
-o ${i} = "docs/change_log.xml" -o ${i} = "docs/old_change_log.xml" \
|
|
|
|
-o ${i} = "docs/index.xml" ]
|
2011-05-22 23:05:12 +08:00
|
|
|
then
|
|
|
|
DATE=$DATE_TODAY
|
|
|
|
else
|
|
|
|
get_last_modified_date ${i}
|
|
|
|
DATE=$RESULT
|
|
|
|
fi;
|
|
|
|
|
|
|
|
#make web version
|
|
|
|
cat docs/stylesheet.xsl | sed -e 's/"is_chm">[^<]*/"is_chm">false/' -e "s/_CURRENT_RELEASE_/$RELEASE/" -e "s/_LAST_MODIFIED_DATE_/$DATE/" \
|
|
|
|
> docs/stylesheet.$$.xsl
|
|
|
|
OUT_FILE=$(echo ${i} | sed -e "s/\.xml/\.html/" | sed -e "s/docs\//docs\/web\//")
|
|
|
|
xsltproc $XSLT_OPTIONS -o $OUT_FILE docs/stylesheet.$$.xsl ${i}
|
|
|
|
|
|
|
|
#make chm version
|
|
|
|
cat docs/stylesheet.xsl | sed -e 's/"is_chm">[^<]*/"is_chm">true/' -e "s/_CURRENT_RELEASE_/$RELEASE/" -e "s/_LAST_MODIFIED_DATE_/$DATE/" \
|
|
|
|
> docs/stylesheet.$$.xsl
|
|
|
|
OUT_FILE=$(echo ${i} | sed -e "s/\.xml/\.html/" | sed -e "s/docs\//docs\/chm\/docs\//")
|
|
|
|
xsltproc $XSLT_OPTIONS -o $OUT_FILE docs/stylesheet.$$.xsl ${i}
|
|
|
|
|
|
|
|
rm docs/stylesheet.$$.xsl
|
|
|
|
done
|
2008-05-02 22:19:38 +08:00
|
|
|
|
2013-05-27 06:46:38 +08:00
|
|
|
# Delete doc type header stuff
|
|
|
|
# FILES=`find docs/chm docs/web -iname "*.html" -type f`
|
|
|
|
# for i in $FILES
|
|
|
|
# do
|
|
|
|
# sed -e '/<!DOCTYPE/d' ${i} > temp.$$;
|
|
|
|
# mv temp.$$ ${i};
|
|
|
|
# done
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
|
|
|
|
echo Generating sitemap
|
|
|
|
cd docs/web || report_failure
|
2010-01-10 03:32:29 +08:00
|
|
|
find . -name "*.html" | awk '{ print "http://dlib.net" substr($1,2)}' > sitemap.txt
|
2010-01-10 03:30:35 +08:00
|
|
|
|
|
|
|
# make the main index have a 301 redirect. Use php to do this
|
|
|
|
echo '<?php if ($_SERVER["SERVER_NAME"] != "dlib.net") { header("Location: http://dlib.net/", true, 301); exit; } ?>' > index.php
|
|
|
|
cat index.html >> index.php
|
|
|
|
rm index.html
|
|
|
|
|
2008-05-02 22:19:38 +08:00
|
|
|
cd ../..
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
./testenv || report_failure
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# build all the html documentation
|
2011-09-21 06:27:47 +08:00
|
|
|
makedocs $1
|
2008-05-02 22:19:38 +08:00
|
|
|
|
|
|
|
# now make the table of contents for the chm file
|
|
|
|
echo Generating the table of contents for the chm file
|
|
|
|
xsltproc -o docs/chm/Table\ of\ Contents.hhc docs/chm/htmlhelp_stylesheet.xsl docs/chm/toc.xml
|
|
|
|
|