Repository: flink-web Updated Branches: refs/heads/asf-site 8d02e41db -> 5ca5915be
update build system for docs Project: http://git-wip-us.apache.org/repos/asf/flink-web/repo Commit: http://git-wip-us.apache.org/repos/asf/flink-web/commit/c718e0de Tree: http://git-wip-us.apache.org/repos/asf/flink-web/tree/c718e0de Diff: http://git-wip-us.apache.org/repos/asf/flink-web/diff/c718e0de Branch: refs/heads/asf-site Commit: c718e0decbd38e16a56113b533fb7144b63aee98 Parents: 8d02e41 Author: Maximilian Michels <[email protected]> Authored: Tue Aug 30 15:01:30 2016 +0200 Committer: Maximilian Michels <[email protected]> Committed: Tue Aug 30 15:30:02 2016 +0200 ---------------------------------------------------------------------- .gitignore | 8 ++- Gemfile | 27 ++++++++++ build.sh | 157 +++++++++----------------------------------------------- 3 files changed, 59 insertions(+), 133 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flink-web/blob/c718e0de/.gitignore ---------------------------------------------------------------------- diff --git a/.gitignore b/.gitignore index 4ff0347..60f9b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,8 @@ -content/build.sh +/content/build.sh +/content/Gemfile +/content/Gemfile.lock +/Gemfile.lock +/_site .DS_Store +/.bundle +/.rubydeps http://git-wip-us.apache.org/repos/asf/flink-web/blob/c718e0de/Gemfile ---------------------------------------------------------------------- diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b7a974c --- /dev/null +++ b/Gemfile @@ -0,0 +1,27 @@ +################################################################################ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +################################################################################ + +source 'https://rubygems.org' + +ruby '>=1.9.0' + +# Dependencies required to build the Flink docs +gem 'jekyll', '2.5.3' +gem 'kramdown', '1.10.0' +gem 'pygments.rb', '0.6.3' +gem 'therubyracer', '0.12.2' http://git-wip-us.apache.org/repos/asf/flink-web/blob/c718e0de/build.sh ---------------------------------------------------------------------- diff --git a/build.sh b/build.sh index 4e95007..2981c4a 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash ################################################################################ # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file @@ -17,149 +17,42 @@ # limitations under the License. ################################################################################ -## -# Functions -## +set -e +cd "$(dirname ${BASH_SOURCE[0]})" -# set -x +DIR="`pwd`" +# We need at least bundler to proceed +if [ "`command -v bundle`" == "" ]; then + echo "WARN: Could not find bundle." + echo "Attempting to install locally. If this doesn't work, please install with 'gem install bundler'." -# Source: http://stackoverflow.com/a/4025065/568695 -vercomp () { - if [[ $1 == $2 ]] - then - return 0 + # Adjust the PATH to discover the locally installed Ruby gem + if which ruby >/dev/null && which gem >/dev/null; then + export PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH" fi - local IFS=. - local i ver1=($1) ver2=($2) - # fill empty fields in ver1 with zeros - for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) - do - ver1[i]=0 - done - for ((i=0; i<${#ver1[@]}; i++)) - do - if [[ -z ${ver2[i]} ]] - then - # fill empty fields in ver2 with zeros - ver2[i]=0 - fi - if ((10#${ver1[i]} > 10#${ver2[i]})) - then - return 1 - fi - if ((10#${ver1[i]} < 10#${ver2[i]})) - then - return 2 - fi - done - return 0 -} -# arguments <branch name> <dirName> -function checkoutDocsForVersionInBranch() { - BRANCH=$1 - DIR=$2 - echo "Checking out docs from branch '$BRANCH' into dir '$DIR' " - - cd flink-src-repo - git checkout $BRANCH - git clean -d -f - - cd docs - - # we are in _root_/flink-src-repo/docs - export BUILD_API=1 - jekyll build --destination ../../docs/$DIR - - # Go back to root of flink website - cd ../../ -} - -# no args -function updateDocsDir() { - echo "Clone if necessary" - if [ ! -d "flink-src-repo" ]; then - git clone http://git-wip-us.apache.org/repos/asf/flink.git flink-src-repo - fi - if [ ! -d "docs" ]; then - mkdir docs - fi - echo "Fetch rep" - cd flink-src-repo - git fetch - cd .. - - echo "Create docs for versions" -# checkoutDocsForVersionInBranch "documentation" "0.5" - checkoutDocsForVersionInBranch "origin/release-0.8" "0.8" - checkoutDocsForVersionInBranch "origin/release-0.7" "0.7-incubating" - checkoutDocsForVersionInBranch "origin/release-0.6.2" "0.6-incubating" -} - -## -# Main body -## - - -HAS_JEKYLL=true - -command -v jekyll > /dev/null -if [ $? -ne 0 ]; then - echo -n "ERROR: Could not find jekyll. " - echo "Please install with 'gem install jekyll' (see http://jekyllrb.com)." - - HAS_JEKYLL=false -fi - -JEKYLL_VERSION=`jekyll --version | cut -d' ' -f2` -vercomp $JEKYLL_VERSION "2.1.0" - -if [ "$?" == "2" ]; then - echo "Please use at least jekyll version 2.1.0 instead of '$JEKYLL_VERSION'" - exit 1 -fi - -command -v redcarpet > /dev/null -if [ $? -ne 0 ]; then - echo -n "WARN: Could not find redcarpet. " - echo -n "Please install with 'sudo gem install redcarpet' (see https://github.com/vmg/redcarpet). " - echo "Redcarpet is needed for Markdown parsing and table of contents generation." + # install bundler locally + gem install --user-install bundler fi -command -v pygmentize > /dev/null -if [ $? -ne 0 ]; then - echo -n "WARN: Could not find pygments. " - echo -n "Please install with 'sudo easy_install pygments' (requires Python; see http://pygments.org). " - echo "Pygments is needed for syntax highlighting of the code examples." -fi - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +# Install Ruby dependencies locally +bundle install --path .rubydeps -SRC=${DIR} -DST=${SRC}/content +DOCS_SRC=${DIR} +DOCS_DST=${DOCS_SRC}/content # default jekyll command is to just build site JEKYLL_CMD="build" - - -OPTIND=1 # if -p flag is provided, serve site on localhost -while getopts ":up" opt; do - case $opt in - p) - JEKYLL_CMD="serve --watch" - ;; - u) - echo "updating docs from repository" - updateDocsDir - ;; - esac +while getopts ":p" opt; do + case $opt in + p) + JEKYLL_CMD="serve --baseurl= --watch" + ;; + esac done -# integrate documentation - -if $HAS_JEKYLL; then - jekyll ${JEKYLL_CMD} --source ${SRC} --destination ${DST} -fi +# use 'bundle exec' to insert the local Ruby dependencies +bundle exec jekyll ${JEKYLL_CMD} --source "${DOCS_SRC}" --destination "${DOCS_DST}"
