Skip to content
Permalink
Browse files
[MINOR] Help text and pwd fix in update-doc.sh
- script failed when run outside bahir-website directory
- add help text
- allow to run for either Bahir (Spark) or Bahir-Flink extensions only
  • Loading branch information
ckadner committed Mar 6, 2017
1 parent 4142e1e commit 9c5bcb98a2a91108f1a6f9e29b18826abb6b6fa9
Showing 1 changed file with 98 additions and 55 deletions.
@@ -16,43 +16,74 @@
# limitations under the License.
#

##############################################################################
# This script generates the documentation for the individual Bahir modules #
# from the README.md files found in the modules in the Bahir source repo #
# #
# bahir (source repo) bahir-website #
# . └─site #
# . └─docs #
# . └─spark #
# ├─sql-streaming-mqtt  └─current #
# │ └─README.md ─────> ├─spark-sql-streaming-mqtt.md #
# ├─streaming-akka │ #
# │ └─README.md ─────> ├─spark-streaming-akka.md #
# ├─streaming-mqtt │ #
# │ └─README.md ─────> ├─spark-streaming-mqtt.md #
# ├─streaming-twitter │ #
# │ └─README.md ─────> ├─spark-streaming-twitter.md #
# └─streaming-zeromq │ #
#  └─README.md ─────> └─spark-streaming-zeromq.md #
# #
# Page header with license text comes from the respective template files #
# under site/docs/spark/templates #
##############################################################################
function exit_with_usage {
cat << EOF
USAGE: update-doc.sh [spark] [flink]
This script generates the documentation for the individual Bahir (Spark) and
Bahir-Flink modules from the contents of the respective module's README.md
files as found in the Bahir and Bahir-Flink source repositories.
bahir (source repo) bahir-website
. └─site
. └─docs
. └─spark
├─sql-streaming-mqtt  └─current
│ └─README.md ─────> ├─spark-sql-streaming-mqtt.md
├─streaming-akka │
│ └─README.md ─────> ├─spark-streaming-akka.md
├─streaming-mqtt │
│ └─README.md ─────> ├─spark-streaming-mqtt.md
├─streaming-twitter │
│ └─README.md ─────> ├─spark-streaming-twitter.md
└─streaming-zeromq │
 └─README.md ─────> └─spark-streaming-zeromq.md
bahir-flink (source repo) bahir-website
. └─site
. └─docs
. └─flink
├─sql-streaming-mqtt  └─current
│ └─README.md ─────> ├─flink-streaming-activemq.md
├─streaming-akka │
│ └─README.md ─────> ├─flink-streaming-akka.md
├─streaming-mqtt │
│ └─README.md ─────> ├─flink-streaming-flume.md
├─streaming-twitter │
│ └─README.md ─────> ├─flink-streaming-netty.md
└─streaming-zeromq │
 └─README.md ─────> └─flink-streaming-redis.md
Page header with license text comes from the respective template files
under:
site/docs/spark/templates
site/docs/flink/templates
EOF
exit 1
}

if [[ "$@" =~ "-h" ]]; then
exit_with_usage
fi

REPOS="${@:-'spark flink'}"

set -e

BASE_DIR=$(pwd)
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

SPARK_WEBSITE_TEMPLATES_DIR=$BASE_DIR/site/docs/spark/templates
SPARK_WEBSITE_DOC_DIR=$BASE_DIR/site/docs/spark/current
SPARK_WEBSITE_TEMPLATES_DIR=site/docs/spark/templates
SPARK_WEBSITE_DOC_DIR=site/docs/spark/current
SPARK_REPO_NAME=bahir
SPARK_BAHIR_SOURCE_DIR=$BASE_DIR/target/$SPARK_REPO_NAME
SPARK_BAHIR_SOURCE_DIR=target/$SPARK_REPO_NAME

FLINK_WEBSITE_TEMPLATES_DIR=$BASE_DIR/site/docs/flink/templates
FLINK_WEBSITE_DOC_DIR=$BASE_DIR/site/docs/flink/current
FLINK_WEBSITE_TEMPLATES_DIR=site/docs/flink/templates
FLINK_WEBSITE_DOC_DIR=site/docs/flink/current
FLINK_REPO_NAME=bahir-flink
FLINK_BAHIR_SOURCE_DIR=$BASE_DIR/target/$FLINK_REPO_NAME
FLINK_BAHIR_SOURCE_DIR=target/$FLINK_REPO_NAME

function checkout_code {
# Checkout code
@@ -80,11 +111,13 @@ function update_docs {

[ ! -d "$WEBSITE_DOC_DIR" ] && mkdir "$WEBSITE_DOC_DIR"

echo "Updating documents ..."

while [ $# -ne 0 ]; do
echo "Syncing document $WEBSITE_DOC_DIR/$1.md with source $SOURCE_DIR/$2/README.md"
echo " $WEBSITE_DOC_DIR/$1.md <-- $SOURCE_DIR/$2/README.md"
rm -f "$WEBSITE_DOC_DIR/$1.md"
cp "$WEBSITE_TEMPLATES_DIR/$1.template" "$WEBSITE_DOC_DIR/$1.md"
cat "$SOURCE_DIR/$2/README.md" >> "$WEBSITE_DOC_DIR/$1.md"
cp "$WEBSITE_TEMPLATES_DIR/$1.template" "$WEBSITE_DOC_DIR/$1.md"
cat "$SOURCE_DIR/$2/README.md" >> "$WEBSITE_DOC_DIR/$1.md"
shift 2
done
}
@@ -94,7 +127,7 @@ function check_version_strings {
echo
echo "TODO: Replace '...-SNAPSHOT' version strings:"
echo
grep -r -n "[0-9]-SNAPSHOT" "$1"/*.md | sed -e 's|'"$(pwd)"/'||g' | grep --color "[0-9.]*-SNAPSHOT"
grep -r -n "[0-9]-SNAPSHOT" "$1"/*.md | sed 's/^/ /' | grep --color "[0-9.]*-SNAPSHOT"
echo
echo "i.e. to replace '2.1.0-SNAPSHOT' with '2.0.2' run the following command:"
echo
@@ -108,34 +141,44 @@ function check_version_strings {
fi
}

echo
echo "================= Updating Apache Spark Extension documents ================="
echo
function update_spark {
echo
echo "================= Updating Apache Spark Extension documents ================="
echo

checkout_code $SPARK_REPO_NAME
checkout_code $SPARK_REPO_NAME

update_docs "$SPARK_WEBSITE_TEMPLATES_DIR" "$SPARK_WEBSITE_DOC_DIR" "$SPARK_BAHIR_SOURCE_DIR" \
spark-sql-streaming-mqtt sql-streaming-mqtt \
spark-streaming-akka streaming-akka \
spark-streaming-mqtt streaming-mqtt \
spark-streaming-twitter streaming-twitter \
spark-streaming-zeromq streaming-zeromq
update_docs "$SPARK_WEBSITE_TEMPLATES_DIR" \
"$SPARK_WEBSITE_DOC_DIR" "$SPARK_BAHIR_SOURCE_DIR" \
spark-sql-streaming-mqtt sql-streaming-mqtt \
spark-streaming-akka streaming-akka \
spark-streaming-mqtt streaming-mqtt \
spark-streaming-twitter streaming-twitter \
spark-streaming-zeromq streaming-zeromq

check_version_strings "$SPARK_WEBSITE_DOC_DIR"
check_version_strings "$SPARK_WEBSITE_DOC_DIR"
}

echo
echo "================= Updating Apache Flink Extension documents ================="
echo
function update_flink {
echo
echo "================= Updating Apache Flink Extension documents ================="
echo

checkout_code $FLINK_REPO_NAME
checkout_code $FLINK_REPO_NAME

update_docs "$FLINK_WEBSITE_TEMPLATES_DIR" \
"$FLINK_WEBSITE_DOC_DIR" "$FLINK_BAHIR_SOURCE_DIR" \
flink-streaming-activemq flink-connector-activemq \
flink-streaming-akka flink-connector-akka \
flink-streaming-flume flink-connector-flume \
flink-streaming-netty flink-connector-netty \
flink-streaming-redis flink-connector-redis

check_version_strings "$FLINK_WEBSITE_DOC_DIR"
}

update_docs "$FLINK_WEBSITE_TEMPLATES_DIR" "$FLINK_WEBSITE_DOC_DIR" "$FLINK_BAHIR_SOURCE_DIR" \
flink-streaming-activemq flink-connector-activemq \
flink-streaming-akka flink-connector-akka \
flink-streaming-flume flink-connector-flume \
flink-streaming-netty flink-connector-netty \
flink-streaming-redis flink-connector-redis

check_version_strings "$FLINK_WEBSITE_DOC_DIR"
[[ "$REPOS" =~ "spark" ]] && update_spark
[[ "$REPOS" =~ "flink" ]] && update_flink

set +e

0 comments on commit 9c5bcb9

Please sign in to comment.