2017-07-26 12:38:51 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
|
2020-02-09 05:20:47 -05:00
|
|
|
# Script to create SQL API and config docs. This requires `mkdocs` and to build
|
2017-07-26 12:38:51 -04:00
|
|
|
# Spark first. After running this script the html docs can be found in
|
|
|
|
# $SPARK_HOME/sql/site
|
|
|
|
|
|
|
|
set -o pipefail
|
|
|
|
set -e
|
|
|
|
|
|
|
|
FWDIR="$(cd "`dirname "${BASH_SOURCE[0]}"`"; pwd)"
|
|
|
|
SPARK_HOME="$(cd "`dirname "${BASH_SOURCE[0]}"`"/..; pwd)"
|
|
|
|
|
2021-01-05 05:48:10 -05:00
|
|
|
if ! hash python3 2>/dev/null; then
|
|
|
|
echo "Missing python3 in your path, skipping SQL documentation generation."
|
2017-07-26 12:38:51 -04:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! hash mkdocs 2>/dev/null; then
|
[SPARK-21773][BUILD][DOCS] Installs mkdocs if missing in the path in SQL documentation build
## What changes were proposed in this pull request?
This PR proposes to install `mkdocs` by `pip install` if missing in the path. Mainly to fix Jenkins's documentation build failure in `spark-master-docs`. See https://amplab.cs.berkeley.edu/jenkins/job/spark-master-docs/3580/console.
It also adds `mkdocs` as requirements in `docs/README.md`.
## How was this patch tested?
I manually ran `jekyll build` under `docs` directory after manually removing `mkdocs` via `pip uninstall mkdocs`.
Also, tested this in the same way but on CentOS Linux release 7.3.1611 (Core) where I built Spark few times but never built documentation before and `mkdocs` is not installed.
```
...
Moving back into docs dir.
Moving to SQL directory and building docs.
Missing mkdocs in your path, trying to install mkdocs for SQL documentation generation.
Collecting mkdocs
Downloading mkdocs-0.16.3-py2.py3-none-any.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 574kB/s
Requirement already satisfied: PyYAML>=3.10 in /usr/lib64/python2.7/site-packages (from mkdocs)
Collecting livereload>=2.5.1 (from mkdocs)
Downloading livereload-2.5.1-py2-none-any.whl
Collecting tornado>=4.1 (from mkdocs)
Downloading tornado-4.5.1.tar.gz (483kB)
100% |████████████████████████████████| 491kB 1.4MB/s
Collecting Markdown>=2.3.1 (from mkdocs)
Downloading Markdown-2.6.9.tar.gz (271kB)
100% |████████████████████████████████| 276kB 2.4MB/s
Collecting click>=3.3 (from mkdocs)
Downloading click-6.7-py2.py3-none-any.whl (71kB)
100% |████████████████████████████████| 71kB 2.8MB/s
Requirement already satisfied: Jinja2>=2.7.1 in /usr/lib/python2.7/site-packages (from mkdocs)
Requirement already satisfied: six in /usr/lib/python2.7/site-packages (from livereload>=2.5.1->mkdocs)
Requirement already satisfied: backports.ssl_match_hostname in /usr/lib/python2.7/site-packages (from tornado>=4.1->mkdocs)
Collecting singledispatch (from tornado>=4.1->mkdocs)
Downloading singledispatch-3.4.0.3-py2.py3-none-any.whl
Collecting certifi (from tornado>=4.1->mkdocs)
Downloading certifi-2017.7.27.1-py2.py3-none-any.whl (349kB)
100% |████████████████████████████████| 358kB 2.1MB/s
Collecting backports_abc>=0.4 (from tornado>=4.1->mkdocs)
Downloading backports_abc-0.5-py2.py3-none-any.whl
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python2.7/site-packages (from Jinja2>=2.7.1->mkdocs)
Building wheels for collected packages: tornado, Markdown
Running setup.py bdist_wheel for tornado ... done
Stored in directory: /root/.cache/pip/wheels/84/83/cd/6a04602633457269d161344755e6766d24307189b7a67ff4b7
Running setup.py bdist_wheel for Markdown ... done
Stored in directory: /root/.cache/pip/wheels/bf/46/10/c93e17ae86ae3b3a919c7b39dad3b5ccf09aeb066419e5c1e5
Successfully built tornado Markdown
Installing collected packages: singledispatch, certifi, backports-abc, tornado, livereload, Markdown, click, mkdocs
Successfully installed Markdown-2.6.9 backports-abc-0.5 certifi-2017.7.27.1 click-6.7 livereload-2.5.1 mkdocs-0.16.3 singledispatch-3.4.0.3 tornado-4.5.1
Generating markdown files for SQL documentation.
Generating HTML files for SQL documentation.
INFO - Cleaning site directory
INFO - Building documentation to directory: .../spark/sql/site
Moving back into docs dir.
Making directory api/sql
cp -r ../sql/site/. api/sql
Source: .../spark/docs
Destination: .../spark/docs/_site
Generating...
done.
Auto-regeneration: disabled. Use --watch to enable.
```
Author: hyukjinkwon <gurwls223@gmail.com>
Closes #18984 from HyukjinKwon/sql-doc-mkdocs.
2017-08-20 06:48:04 -04:00
|
|
|
echo "Missing mkdocs in your path, trying to install mkdocs for SQL documentation generation."
|
2021-01-05 05:48:10 -05:00
|
|
|
pip3 install mkdocs
|
2017-07-26 12:38:51 -04:00
|
|
|
fi
|
|
|
|
|
2017-08-26 00:56:24 -04:00
|
|
|
pushd "$FWDIR" > /dev/null
|
|
|
|
|
2017-07-26 12:38:51 -04:00
|
|
|
rm -fr docs
|
|
|
|
mkdir docs
|
|
|
|
|
2020-02-09 05:20:47 -05:00
|
|
|
echo "Generating SQL API Markdown files."
|
|
|
|
"$SPARK_HOME/bin/spark-submit" gen-sql-api-docs.py
|
|
|
|
|
2020-04-27 04:08:52 -04:00
|
|
|
echo "Generating SQL configuration table HTML file."
|
|
|
|
"$SPARK_HOME/bin/spark-submit" gen-sql-config-docs.py
|
2020-02-09 05:20:47 -05:00
|
|
|
|
2020-04-20 21:55:13 -04:00
|
|
|
echo "Generating HTML files for SQL function table and examples."
|
|
|
|
"$SPARK_HOME/bin/spark-submit" gen-sql-functions-docs.py
|
|
|
|
|
2020-02-09 05:20:47 -05:00
|
|
|
echo "Generating HTML files for SQL API documentation."
|
2017-07-26 12:38:51 -04:00
|
|
|
mkdocs build --clean
|
|
|
|
rm -fr docs
|
2017-08-26 00:56:24 -04:00
|
|
|
|
|
|
|
popd
|