1111
1212set -e
1313
14+
1415if [ $# -eq 0 ]
1516 then
1617 echo " No playbook supplied, using default playbook"
2223SCRIPT_DIR=$( cd -- " $( dirname -- " ${BASH_SOURCE[0]} " ) " & > /dev/null && pwd )
2324cd " $SCRIPT_DIR "
2425
26+ if [ -n " ${CIRCLE_REPOSITORY_URL:- } " ]; then
27+ account=" ${CIRCLE_REPOSITORY_URL#*: } "
28+ account=" ${account%%/* } "
29+ lib=$( basename " $( git rev-parse --show-toplevel) " )
30+ repository=" ${account} /$lib "
31+ sha=${CIRCLE_SHA1}
32+ elif [ -n " ${GITHUB_REPOSITORY:- } " ]; then
33+ repository=" ${GITHUB_REPOSITORY} "
34+ sha=${GITHUB_SHA}
35+ fi
36+
37+ if [ -n " ${repository} " ] && [ -n " ${sha} " ]; then
38+ base_url=" https://github.com/${repository} /blob/${sha} "
39+ echo " Setting base-url to $base_url "
40+ cp mrdocs.yml mrdocs.yml.bak
41+ perl -i -pe ' s{^\s*base-url:.*$}{base-url: ' " $base_url /" ' }' mrdocs.yml
42+ fi
43+
2544echo " Building documentation with Antora..."
2645echo " Installing npm dependencies..."
2746npm ci
@@ -37,4 +56,15 @@ for f in $(find html -name '*.html'); do
3756 perl -i -pe ' s{{{(.*?)}}}{<a href="../../../$1.html">$1</a>}g' " $f "
3857done
3958
59+ if [ -n " ${base_url:- } " ]; then
60+ if [ -f mrdocs.yml.bak ]; then
61+ mv -f mrdocs.yml.bak mrdocs.yml
62+ echo " Restored original mrdocs.yml"
63+ else
64+ echo " mrdocs.yml.bak not found; skipping restore"
65+ fi
66+ perl -i -pe " s[{{BASE_URL}}][$base_url ]g" \
67+ html/openmethod/ref_headers.html html/openmethod/BOOST_OPENMETHOD* .html
68+ fi
69+
4070echo " Done"
0 commit comments