Skip to content

Instantly share code, notes, and snippets.

@drdanz
Created June 23, 2016 09:36
Show Gist options
  • Save drdanz/475d513095cbb8947f0bedce3d53beac to your computer and use it in GitHub Desktop.
Save drdanz/475d513095cbb8947f0bedce3d53beac to your computer and use it in GitHub Desktop.
#!/bin/bash
#=============================================================================
# Copyright 2014, 2016 iCub Facility, Istituto Italiano di Tecnologia
# Authors: Daniele E. Domenichelli <daniele.domenichelli@iit.it>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of YARP, substitute the full
# License text for the above reference.)
if [ $# -gt 1 ]; then
echo "Usage: $(basename $0) [remote (default=origin)]"
fi
if [ ! -f conf/template/YARPConfig.cmake.in ]; then
echo "You must run this script in YARP main dir"
exit 1
fi
if [ $# -eq 1 ]; then
remote=$1
else
remote=origin
fi
git fetch -q --prune $remote
git checkout gh-pages || git checkout -b gh-pages || exit 1
git rebase -q $remote/devel || exit 1
git reset $remote/devel || exit 1
# rm -Rf build-docs
if [ ! -d build-docs ]; then
git clone -q $PWD --no-hardlinks --branch devel --origin local build-docs || exit 1
(cd build-docs && git remote add $remote $(git -C .. config --get remote.$remote.url)) || exit 1
fi
(cd build-docs && git fetch --prune local && git fetch --prune $remote && git checkout devel && git reset --hard $remote/devel) || exit 1
cat > index.html << EOF
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh" content="1;url=gh-pages/devel/index.html">
<script type="text/javascript">
window.location.href = "gh-pages/devel/index.html"
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, follow the <a href='gh-pages/devel/index.html'>link to YARP documentation.</a>
</body>
</html>
EOF
rm -Rf gh-pages
mkdir -p gh-pages
branches="master devel"
tags=$(git for-each-ref --format="%(refname)" refs/tags/ | sed "s#refs/tags/##" | grep -v "start" | sort -V)
for ref in $branches; do
rm -Rf gh-pages/$ref/
done
for ref in $tags $branches; do
echo Generating documentation for ref $ref
if [ ! -d gh-pages/$ref/ ]; then
(cd build-docs && git checkout -q $ref)
mkdir -p build-docs/build-$ref
(cd build-docs/build-$ref && cmake ../../ -DYARP_DOXYGEN_HTML:BOOL=TRUE -DYARP_DOXYGEN_TAGFILE:BOOL=TRUE -DYARP_DOXYGEN_HTML_QHP:BOOL=ON && make dox) > build-docs/$ref.log 2>&1
if [ -d build-docs/build-$ref/dox/html/ ]; then
cp -a build-docs/build-$ref/dox/html/ gh-pages/$ref
if [ -f build-docs/build-$ref/dox/YARP.tag ]; then
cp -R build-docs/build-$ref/dox/YARP.tag gh-pages/$ref/YARP.tag
fi
echo " done"
else
echo " WARNING: no documentation produced"
fi
else
echo " nothing to do"
fi
rm -Rf build-docs/build-$ref
# Fix paths
(cd gh-pages/$ref/ && grep -Rl eris.liralab.it | xargs sed -i 's|eris.liralab.it|wiki.icub.org|g' 2>/dev/null)
(cd gh-pages/$ref/ && grep -Rl http://wiki.icub.org/yarpdoc/ | xargs sed -i 's|http://wiki.icub.org/yarpdoc/||g' 2>/dev/null)
echo "-------------------------------"
done
# rm -Rf build-docs
git add gh-pages/ index.html
git commit -q -m "Generate documentation"
git checkout -q devel || exit 1
echo
echo "Finished. You can now push with"
echo
echo " git push --force $remote gh-pages"
echo
@drdanz
Copy link
Author

drdanz commented Jun 23, 2016

Generate the gh-pages for YARP including the documentation for master and devel branches and for all tags.
The main index points to the devel branch documentation.

WARNING The size of the whole documentation is huge (~12Gb)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment