Skip to content

Commit

Permalink
[FLINK-13793][docs] build each language in a separate subprocess
Browse files Browse the repository at this point in the history
When not serving docs and just building them, e.g. via `./build_docs.sh`, we
spawn sub-processes for each language build instead of running them
single-threaded (jekyll currently does not support parallel builds).
  • Loading branch information
NicoK committed Feb 13, 2020
1 parent 114f2b4 commit cf27ba2
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
.jekyll-cache/
.rubydeps/
content/
content_*/
ruby2/.bundle/
ruby2/.rubydeps/
3 changes: 3 additions & 0 deletions docs/_config_dev_en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@

exclude:
- "*.zh.md"
- "content"
- "content_en"
- "content_zh"
3 changes: 3 additions & 0 deletions docs/_config_dev_zh.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

exclude:
- "*.md"
- "content"
- "content_en"
- "content_zh"

include:
- "*.zh.md"
28 changes: 27 additions & 1 deletion docs/build_docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ JEKYLL_CMD="build"

JEKYLL_CONFIG=""

DOC_LANGUAGES="en zh"

# if -p flag is provided, serve site on localhost
# -i is like -p, but incremental (only rebuilds the modified file)
# -e builds only english documentation
Expand All @@ -78,4 +80,28 @@ while getopts "piez" opt; do
done

# use 'bundle exec' to insert the local Ruby dependencies
bundle exec jekyll ${JEKYLL_CMD} ${JEKYLL_CONFIG} --source "${DOCS_SRC}" --destination "${DOCS_DST}"

if [ "${JEKYLL_CMD}" = "build" ] && [ -z "${JEKYLL_CONFIG}" ]; then
# run parallel builds for all languages if not serving or creating a single language only

# run processes and store pids
echo "Spawning parallel builds for languages: ${DOC_LANGUAGES}..."
pids=""
for lang in ${DOC_LANGUAGES}; do
bundle exec jekyll ${JEKYLL_CMD} --config _config.yml,_config_dev_${lang}.yml --source "${DOCS_SRC}" --destination "${DOCS_DST}_${lang}" &
pid=$!
pids="${pids} ${pid}"
done

# wait for all pids (since jekyll returns 0 even in case of failures, we do not parse exit codes)
wait ${pids}
rm -rf "${DOCS_DST}"
mkdir -p "${DOCS_DST}"
for lang in ${DOC_LANGUAGES}; do
cp -aln "${DOCS_DST}_${lang}/." "${DOCS_DST}"
rm -rf "${DOCS_DST}_${lang}"
done
exit 0
else
bundle exec jekyll ${JEKYLL_CMD} ${JEKYLL_CONFIG} --source "${DOCS_SRC}" --destination "${DOCS_DST}"
fi

0 comments on commit cf27ba2

Please sign in to comment.