generate_latest_docs.sh 2.4 KB

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