summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSeth Tisue <seth@tisue.net>2015-12-18 14:49:42 -0500
committerSeth Tisue <seth@tisue.net>2015-12-18 14:49:42 -0500
commit6792b57152e70fd818db84829c0fb3d8e3899c26 (patch)
treeca46281cd0b98a8359b471b4cf6228a7d53b8350 /tools
parentcc90f7744d8f24404cf745def5ace6c41c618746 (diff)
parent006c0a4a343749f9a6a591e5cdec925effe1103a (diff)
downloadscala-6792b57152e70fd818db84829c0fb3d8e3899c26.tar.gz
scala-6792b57152e70fd818db84829c0fb3d8e3899c26.tar.bz2
scala-6792b57152e70fd818db84829c0fb3d8e3899c26.zip
Merge pull request #4765 from janekdb/2.11.x-scaladoc-diff
Script to compare the current scaladoc with the parent commit's doc
Diffstat (limited to 'tools')
-rwxr-xr-xtools/scaladoc-diff117
1 files changed, 117 insertions, 0 deletions
diff --git a/tools/scaladoc-diff b/tools/scaladoc-diff
new file mode 100755
index 0000000000..df0d1f3335
--- /dev/null
+++ b/tools/scaladoc-diff
@@ -0,0 +1,117 @@
+#!/usr/bin/env bash
+#
+# Script to compare the scaladoc of the current commit with the scaladoc
+# of the parent commit. No arguments.
+#
+
+set -e
+
+# opendiff for Mac OS X, meld for Ubuntu then default to other commands.
+displaydiff() {
+ case "$(uname -s)" in
+
+ Darwin)
+ if hash opendiff 2>/dev/null; then
+ echo opendiff "$@"
+ opendiff "$@"
+ else
+ echo diff "$@"
+ diff -y "$@" | less -N
+ fi
+ ;;
+
+ *)
+ if hash meld 2>/dev/null; then
+ echo meld "$@"
+ meld "$@"
+ elif hash gvimdiff 2>/dev/null; then
+ echo gvimdiff "$@"
+ gvimdiff "$@"
+ else
+ echo diff "$@"
+ diff -y "$@" | less -N
+ fi
+ ;;
+ esac
+}
+
+oldsha=$(git rev-parse --short HEAD^)
+
+# Use branch name defaulting to SHA1 when not available for example when in
+# detached HEAD state.
+sha=$(git symbolic-ref -q --short HEAD || git rev-parse --short HEAD)
+
+echo "parent commit sha : $oldsha"
+echo "current commit sha : $sha"
+
+# create scaladoc for parent commit if not done already
+if [ ! -f "build/scaladoc-output-$oldsha.txt" ]
+then
+ echo "making scaladoc for parent commit ($oldsha)"
+ git checkout -q $oldsha
+ ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$oldsha.txt
+ rm -rf build/scaladoc-${oldsha}
+ mv build/scaladoc build/scaladoc-${oldsha}
+ git checkout -q $sha
+fi
+
+# create scaladoc for current commit
+echo "making scaladoc for current commit ($sha)"
+ant docs.lib -Dscaladoc.raw.output='yes' > build/scaladoc-output-$sha.txt
+rm -rf build/scaladoc-${sha}
+mv build/scaladoc build/scaladoc-${sha}
+
+# Allow script to continue when diff results in -1
+set +e
+
+displaydiff build/scaladoc-output-$oldsha.txt build/scaladoc-output-$sha.txt
+
+# Adapted from tools/scaladoc-compare
+echo "Comparing versions with diff: build/scaladoc-${sha}/ build/scaladoc-$oldsha/"
+NEW_PATH=build/scaladoc-${sha}/
+OLD_PATH=build/scaladoc-$oldsha/
+
+
+NEWFILES=$(find $NEW_PATH -name '*.html.raw')
+if [ "$NEWFILES" == "" ]
+then
+ echo "No .html.raw files found in $NEW_PATH!"
+ exit 1
+fi
+
+for NEW_FILE in $NEWFILES
+do
+ OLD_FILE=${NEW_FILE/$NEW_PATH/$OLD_PATH}
+ if [ -f $OLD_FILE ]
+ then
+ DIFF=$(diff -q -w $NEW_FILE $OLD_FILE 2>&1)
+ if [ "$DIFF" != "" ]
+ then
+ displaydiff $OLD_FILE $NEW_FILE > /dev/null
+
+ echo "next [y\N]? "
+ read -n 1 -s input
+ if [ "$input" == "N" ]; then exit 0; fi
+ fi
+ else
+ echo
+ echo "New file: : $NEW_FILE"
+ echo "No corresponding old file : $OLD_FILE"
+
+ echo "next [y\N]? "
+ read -n 1 -s input
+ if [ "$input" == "N" ]; then exit 0; fi
+ fi
+done
+
+OLDFILES=$(find $OLD_PATH -name '*.html.raw')
+for OLD_FILE in $OLDFILES
+do
+ NEW_FILE=${OLD_FILE/$OLD_PATH/$NEW_PATH}
+ if [ ! -f $NEW_FILE ]
+ then
+ echo
+ echo "Old file: : $OLD_FILE"
+ echo "No corresponding new file : $NEW_FILE"
+ fi
+done