Skip to content

Commit aec8b5a

Browse files
committed
[FLINK-3887] improve dependency management for building docs
The Flink documentation build process is currently quite messy. These changes move us to a new build process with proper dependency handling. It assures that we all use the same dependency versions for consistent build output. Also, it eases the automated building process on other systems (like the ASF Buildbot). The goal was to make the documentation build process easier and self-contained. - use Ruby's Bundler Gem to install dependencies - update README - adapt Dockerfile - add additional rules to .gitignore - change default doc output path from /target to /content (default path of the flink-web repository) This closes apache#2033
1 parent c60326f commit aec8b5a

File tree

6 files changed

+67
-48
lines changed

6 files changed

+67
-48
lines changed

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,15 @@ tmp
1616
*.jar
1717
*.log
1818
.DS_Store
19-
_site
20-
docs/api
2119
build-target
2220
flink-batch-connectors/flink-avro/src/test/java/org/apache/flink/api/io/avro/generated/
2321
flink-runtime-web/web-dashboard/assets/fonts/
2422
flink-runtime-web/web-dashboard/node_modules/
2523
flink-runtime-web/web-dashboard/bower_components/
2624
atlassian-ide-plugin.xml
2725
out/
26+
/docs/api
27+
/docs/content
28+
/docs/Gemfile.lock
29+
/docs/.bundle
30+
/docs/.rubydeps

docs/Gemfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
source 'https://rubygems.org'
20+
21+
# Dependencies required to build the Flink docs
22+
gem 'jekyll', '2.5.3'
23+
gem 'kramdown', '1.10.0'
24+
gem 'pygments.rb', '0.6.3'
25+
gem 'therubyracer', '0.12.2'

docs/README.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@ http://flink.apache.org/ is also generated from the files found here.
66

77
# Requirements
88

9-
We use Markdown to write and Jekyll to translate the documentation to static HTML. Kramdown is
10-
needed for Markdown processing and the Python based Pygments is used for syntax highlighting. To run
11-
Javascript code from Ruby, you need to install a javascript runtime (e.g. `therubyracer`). You can
12-
install all needed software via the following commands:
9+
The dependencies are declared in the Gemfile in this directory. We use Markdown
10+
to write and Jekyll to translate the documentation to static HTML. All required
11+
dependencies are installed locally when you build the documentation through the
12+
`build_docs.sh` script. If you want to install the software manually, use Ruby's
13+
Bundler Gem to install all dependencies:
1314

14-
gem install jekyll -v 2.5.3
15-
gem install kramdown -v 1.9.0
16-
gem install pygments.rb -v 0.6.3
17-
gem install therubyracer -v 0.12.2
18-
sudo easy_install Pygments
15+
gem install bundler
16+
bundle install
1917

20-
Note that in Ubuntu based systems, it may be necessary to install the `ruby-dev` and
21-
`python-setuptools` packages via apt.
18+
Note that in Ubuntu based systems, it may be necessary to install the `ruby-dev`
19+
via apt to build native code.
2220

2321
# Using Dockerized Jekyll
2422

@@ -35,11 +33,13 @@ The run.sh command brings you in a bash session where you can run following doc
3533

3634
# Build
3735

38-
The `docs/build_docs.sh` script calls Jekyll and generates the documentation in `docs/target`. You
39-
can then point your browser to `docs/target/index.html` and start reading.
36+
The `docs/build_docs.sh` script installs dependencies locally, calls Jekyll, and
37+
generates the documentation in `docs/content`. You can then point your browser
38+
to `docs/content/index.html` and start reading.
4039

41-
If you call the script with the preview flag `build_docs.sh -p`, Jekyll will start a web server at
42-
`localhost:4000` and watch the docs directory for updates. Use this mode to preview changes locally.
40+
If you call the script with the preview flag `build_docs.sh -p`, Jekyll will
41+
start a web server at `localhost:4000` and watch the docs directory for
42+
updates. Use this mode to preview changes locally.
4343

4444
# Contribute
4545

docs/build_docs.sh

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,35 +17,30 @@
1717
# limitations under the License.
1818
################################################################################
1919

20+
set -e
21+
cd "$(dirname ${BASH_SOURCE[0]})"
2022

21-
HAS_JEKYLL=true
23+
DIR="`pwd`"
2224

23-
command -v jekyll > /dev/null
24-
if [ $? -ne 0 ]; then
25-
echo -n "ERROR: Could not find jekyll. "
26-
echo "Please install with 'gem install jekyll' (see http://jekyllrb.com)."
25+
# We need at least bundler to proceed
26+
if [ "`command -v bundle`" == "" ]; then
27+
echo "WARN: Could not find bundle."
28+
echo "Attempting to install locally. If this doesn't work, please install with 'gem install bundler'."
2729

28-
HAS_JEKYLL=false
29-
fi
30-
31-
command -v redcarpet > /dev/null
32-
if [ $? -ne 0 ]; then
33-
echo -n "WARN: Could not find redcarpet. "
34-
echo -n "Please install with 'sudo gem install redcarpet' (see https://github.com/vmg/redcarpet). "
35-
echo "Redcarpet is needed for Markdown parsing and table of contents generation."
36-
fi
30+
# Adjust the PATH to discover the locally installed Ruby gem
31+
if which ruby >/dev/null && which gem >/dev/null; then
32+
export PATH="$(ruby -rubygems -e 'puts Gem.user_dir')/bin:$PATH"
33+
fi
3734

38-
command -v pygmentize > /dev/null
39-
if [ $? -ne 0 ]; then
40-
echo -n "WARN: Could not find pygments. "
41-
echo -n "Please install with 'sudo easy_install Pygments' (requires Python; see http://pygments.org). "
42-
echo "Pygments is needed for syntax highlighting of the code examples."
35+
# install bundler locally
36+
gem install --user-install bundler
4337
fi
4438

45-
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
39+
# Install Ruby dependencies locally
40+
bundle install --path .rubydeps
4641

4742
DOCS_SRC=${DIR}
48-
DOCS_DST=${DOCS_SRC}/target
43+
DOCS_DST=${DOCS_SRC}/content
4944

5045
# default jekyll command is to just build site
5146
JEKYLL_CMD="build"
@@ -59,6 +54,5 @@ while getopts ":p" opt; do
5954
esac
6055
done
6156

62-
if $HAS_JEKYLL; then
63-
jekyll ${JEKYLL_CMD} --source ${DOCS_SRC} --destination ${DOCS_DST}
64-
fi
57+
# use 'bundle exec' to insert the local Ruby dependencies
58+
bundle exec "jekyll ${JEKYLL_CMD} --source '${DOCS_SRC}' --destination '${DOCS_DST}'"

docs/docker/Dockerfile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,5 @@
1717
FROM centos:centos7
1818

1919
RUN yum install -y vim gem ruby-devel make gcc gcc-c++ python-setuptools && \
20-
gem install jekyll -v 2.5.3 && \
21-
gem install kramdown -v 1.9.0 && \
22-
gem install pygments.rb -v 0.6.3 && \
23-
gem install therubyracer -v 0.12.2 && \
24-
easy_install Pygments
20+
gem install bundler
2521

pom.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,11 +864,12 @@ under the License.
864864
</licenseFamilies>
865865
<excludes>
866866
<!-- Additional files like .gitignore etc.-->
867-
<exclude>**/.*</exclude>
867+
<exclude>**/.*/**</exclude>
868868
<exclude>**/*.prefs</exclude>
869869
<exclude>**/*.log</exclude>
870870
<!-- External web libraries. -->
871871
<exclude>docs/**/bootstrap*</exclude>
872+
<exclude>docs/Gemfile.lock</exclude>
872873
<exclude>docs/img/*.svg</exclude>
873874
<exclude>**/resources/**/font-awesome/**</exclude>
874875
<exclude>**/resources/**/jquery*</exclude>
@@ -921,7 +922,7 @@ under the License.
921922
<!-- Generated content -->
922923
<exclude>out/**</exclude>
923924
<exclude>**/target/**</exclude>
924-
<exclude>docs/_site/**</exclude>
925+
<exclude>docs/content/**</exclude>
925926
<exclude>**/scalastyle-output.xml</exclude>
926927
<exclude>build-target/**</exclude>
927928
<!-- Tools: watchdog -->

0 commit comments

Comments
 (0)