Tools used by OpenStack Documentation
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

114 lines
2.8 KiB

  1. #!/bin/bash -e
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. DIRECTORY=$1
  15. if [ -z "$DIRECTORY" ] ; then
  16. echo "usage $0 DIRECTORY options"
  17. echo "Options are:"
  18. echo "--tag TAG: Use given tag for building"
  19. echo "--target TARGET: Copy files to publish-docs/html/$TARGET"
  20. echo "--build BUILD: Name of build directory"
  21. echo "--linkcheck: Check validity of links instead of building"
  22. echo "--pdf: PDF file generation"
  23. exit 1
  24. fi
  25. TARGET=""
  26. TAG=""
  27. TAG_OPT=""
  28. BUILD=""
  29. LINKCHECK=""
  30. PDF=""
  31. while [[ $# > 0 ]] ; do
  32. option="$1"
  33. case $option in
  34. --build)
  35. BUILD="$2"
  36. shift
  37. ;;
  38. --linkcheck)
  39. LINKCHECK=1
  40. ;;
  41. --tag)
  42. TAG="$2"
  43. TAG_OPT="-t $2"
  44. shift
  45. ;;
  46. --target)
  47. TARGET="$2"
  48. shift
  49. ;;
  50. --pdf)
  51. PDF=1
  52. ;;
  53. esac
  54. shift
  55. done
  56. if [ -z "$BUILD" ] ; then
  57. if [ -z "$TAG" ] ; then
  58. BUILD_DIR="$DIRECTORY/build/html"
  59. BUILD_DIR_PDF="$DIRECTORY/build/pdf"
  60. else
  61. BUILD_DIR="$DIRECTORY/build-${TAG}/html"
  62. BUILD_DIR_PDF="$DIRECTORY/build-${TAG}/pdf"
  63. fi
  64. else
  65. BUILD_DIR="$DIRECTORY/$BUILD/html"
  66. BUILD_DIR_PDF="$DIRECTORY/$BUILD/pdf"
  67. fi
  68. DOCTREES="${BUILD_DIR}.doctrees"
  69. if [ -z "$TAG" ] ; then
  70. echo "Checking $DIRECTORY..."
  71. else
  72. echo "Checking $DIRECTORY with tag $TAG..."
  73. fi
  74. if [ "$LINKCHECK" = "1" ] ; then
  75. # Show sphinx-build invocation for easy reproduction
  76. set -x
  77. sphinx-build -E -W -d $DOCTREES -b linkcheck \
  78. $TAG_OPT $DIRECTORY/source $BUILD_DIR
  79. set +x
  80. else
  81. # Show sphinx-build invocation for easy reproduction
  82. set -x
  83. sphinx-build -E -W -d $DOCTREES -b html \
  84. $TAG_OPT $DIRECTORY/source $BUILD_DIR
  85. set +x
  86. # PDF generation
  87. if [ "$PDF" = "1" ] ; then
  88. set -x
  89. sphinx-build -E -W -d $DOCTREES -b latex \
  90. $TAG_OPT $DIRECTORY/source $BUILD_DIR_PDF
  91. make -C $BUILD_DIR_PDF
  92. cp $BUILD_DIR_PDF/*.pdf $BUILD_DIR/
  93. set +x
  94. fi
  95. # Copy RST (and PDF)
  96. if [ "$TARGET" != "" ] ; then
  97. mkdir -p publish-docs/html/$TARGET
  98. rsync -a $BUILD_DIR/ publish-docs/html/$TARGET/
  99. # Remove unneeded build artefact
  100. rm -f publish-docs/html/$TARGET/.buildinfo
  101. fi
  102. fi