Skip to content

Commit

Permalink
Block search engines for unofficial or unsupported docs
Browse files Browse the repository at this point in the history
See #239

[makedoc]
  • Loading branch information
GiovanniBussi committed Jun 7, 2017
1 parent 1b4c99c commit 0f618b2
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
41 changes: 41 additions & 0 deletions .travis/pushdoc
Expand Up @@ -3,6 +3,19 @@
set -e
set -x

if [[ "$TRAVIS_BRANCH" =~ ^v2\.[0-9]+$ ]] ; then
# TODO: this should be made automatic by reading the CHANGES/*.txt files:
if [ "$TRAVIS_BRANCH" = v2.0 ] || [ "$TRAVIS_BRANCH" = v2.1 ] || [ "$TRAVIS_BRANCH" = v2.2 ] ; then
branchtype=unsupported
else
branchtype=official
fi
elif [ "$TRAVIS_BRANCH" = master ] ; then
branchtype=master
else
branchtype=unofficial
fi

hash=$( git log -1 --format="%h")

root="$PWD"
Expand Down Expand Up @@ -57,6 +70,34 @@ You can also download a full copy of the manual for offline access
at [this link](http://github.com/plumed/doc-${TRAVIS_BRANCH}/archive/gh-pages.zip).
EOF

case "$branchtype" in
(official) echo "This is the manual for an official and supported PLUMED branch." >> README.md ;;
(unsupported) echo "This is the manual for an official but unsupported PLUMED branch. It will not appear on search engines." >> README.md ;;
(master) echo "This is the manual for an the development PLUMED branch." >> README.md ;;
(unofficial) echo "This is the manual for an unofficial PLUMED branch. It will not appear on search engines." >> README.md ;;
esac

case "$branchtype" in
(unsupported|unofficial)
# this is to avoid a huge log file:
set +x
for file in $(find . -name "*.html") ; do
awk '{
if(done){print; next;}
print
if(match($0,".*<head>.*")){
print "<meta name=\"robots\" content=\"noindex\">"
done=1;
}
}END{
if(!done) print "error: head not present in " FILENAME > "/dev/stderr"
}' $file > $$
mv $$ $file
done
set -x
esac

git add --all .
git commit -m "Update to plumed/plumed2@$hash"
# -q and 2> is not to show the GIT_TOKEN on Travis log
Expand Down
6 changes: 5 additions & 1 deletion developer-doc/usingDoxygen.txt
Expand Up @@ -492,12 +492,16 @@ Notice that Travis CI will try to push the manual on a repository named http://g
this should work for all the future release branches as long as an appropriate repository is created on the github.com/plumed
organization.
We could even easily create repositories to host the documentation of temporary branches.
Also notice that these repositories (plumed-doc-xxx) need to give write access to a dummy github account (PlumedBot). A token
Also notice that these repositories (plumed/doc-xxx) need to give write access to a dummy github account (PlumedBot). A token
for that user enabling html access is stored in the environment variable GIT_TOKEN which is saved (not visible) on travis-ci.org.
In this way, any commit made in the plumed repository by one of the developers will have access to the variable and will trigger
(optionally, when [makedoc] is present) manual build and push. Conversely, pull requests by external users should not be able to
access the token and won't update manual changes.

Notice that to solve [this issue](https://github.com/plumed/plumed2/issues/239) as of PLUMED 2.3.2 the script that
pushes the documentation to travis-ci adds special information to remove from search engine results pages from
unofficial or unsupported branch (see .travis/pushdoc script).

Bottom line: when you make a commit where you modified the manual and you want the online manual to be updated,
add [makedoc] in the commit log. After ten minutes or so the manual should be up to date, remember to double check on the web
and to revert the commit if there are errors!
Expand Down

0 comments on commit 0f618b2

Please sign in to comment.