1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
|
#!/bin/bash
# Rebuild gh-pages branch.
set -e
echo "Preparing to generate documentation..."
COMMIT=${TRAVIS_COMMIT-$(git rev-parse HEAD)}
export GIT_WORK_TREE="$GH_PAGES"
export GIT_DIR="$GH_PAGES/.git"
mkdir -p "$GIT_DIR"
# Files to omit from documentation
BLACKLIST_FILES=(
date/relativecommontests.js
events/eventtargettester.js
i18n/compactnumberformatsymbolsext.js
i18n/datetimepatternsext.js
i18n/listsymbolsext.js
i18n/numberformatsymbolsext.js
promise/testsuiteadapter.js
proto2/package_test.pb.js
proto2/test.pb.js
soy/soy_testhelper.js
style/stylescrollbartester.js
testing/parallel_closure_test_suite.js
test_module.js
test_module_dep.js
tweak/testhelpers.js
transpile.js
useragent/useragenttestutil.js
)
declare -A BLACKLIST
for file in "${BLACKLIST_FILES[@]}"; do
BLACKLIST["$file"]=true
done
# Pull the existing gh-pages branch, but wipe out the workdir
git init
git remote add origin https://github.com/google/closure-library.git
git remote set-url --push origin git@github.com:google/closure-library.git
git pull --depth=10 origin gh-pages > /dev/null
git checkout gh-pages
git config user.email "travis@travis-ci.org"
git config user.name "travis-ci"
find "$GH_PAGES" -mindepth 1 -maxdepth 1 -path "$GH_PAGES/.git" -prune -o \
-exec rm -rf {} \;
# Rearrange files from the repo.
cp -r doc/* "$GH_PAGES/"
mkdir -p "$GH_PAGES/source/closure"
cp -r closure/* "$GH_PAGES/source/closure/"
mkdir -p "$GH_PAGES/api"
# Download the latest js-dossier release.
npm install js-dossier
command=(
java -jar node_modules/js-dossier/dossier.jar
--output "$GH_PAGES/api"
--readme scripts/ci/dossier_readme.md
--source_url_template
'https://github.com/google/closure-library/blob/master/%path%#L%line%'
--type_filter '^goog\.i18n\.\w+_.*'
--type_filter '^goog\.labs\.i18n\.\w+_.*'
--type_filter '^.*+_$'
)
# Explicitly add all the non-blacklisted files.
while read -r file; do
if [[ ! "$file" =~ ^closure/goog/demos &&
! "$file" =~ _test\.js$ &&
! "$file" =~ _perf\.js$ &&
"${BLACKLIST[${file#closure/goog/}]}" != true ]]; then
command=("${command[@]}" --source "$file")
fi
done < <(find closure/goog third_party/closure/goog -name '*.js')
# Run dossier.
"${command[@]}"
BUILD=${TRAVIS_BUILD_NUMBER+ after successful travis build $TRAVIS_BUILD_NUMBER}
# Make a commit.
git add -A
git commit -m "Latest documentation auto-pushed to gh-pages
Built from commit $COMMIT$BUILD."
echo "gh-pages is ready to push in $GH_PAGES."
|