From d8d61ee2d6775e5b07d640e069dbd7b63ec3b636 Mon Sep 17 00:00:00 2001 From: Bob Kerns Date: Tue, 11 Sep 2012 18:45:21 -0700 Subject: [PATCH 1/3] Make jsdoc script work with MinGW and Cygwin On MinGW and Cygwin, we have different representations for pathnames, neither of which Rhino understands. We also have to contend with '\', which is not a legal URI character. And we have to supply a third / after file:// (two before the null hostname, and one before the start of the absolute path). Since Windows paths don't start with /, we have to supply it in that case. We handle the MinGW and Cygwin cases by asking for the information with 'pwd -W' for MinGW and 'cygpath $(pwd)' for Cygwin, before finally falling back to pwd for everyone else. Then, if they don't start with '/' we supply the extra '/' for the URL. --- jsdoc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/jsdoc b/jsdoc index ee9c4edf..9eb02813 100755 --- a/jsdoc +++ b/jsdoc @@ -3,11 +3,18 @@ # rhino discards the path to the current script file, so we must add it back SOURCE="$0" while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done -BASEPATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +# Get a Windows path under MinGW or Cygwin +BASEPATH="$( cd -P "$( dirname "$SOURCE" )" && (pwd -W 2>/dev/null || cygpath -w $(pwd) 2>/dev/null || pwd))" +if [ "${BASEPATH:0:1}" != "/" ] ; then + # We need a extra slash for URLs + UBASEPATH="/$BASEPATH" +else + UBASEPATH="$BASEPATH" +fi # for whatever reason, Rhino requires module paths to be valid URIs -URLPATH="file://"$BASEPATH -URLPATH=`echo "$URLPATH" | sed -e 's/ /%20/g'` +URLPATH="file://$UBASEPATH" +URLPATH=`echo "$URLPATH" | sed -e 's/ /%20/g' -e 's#\\\\#/#g'` ENCODEDBASEPATH=`echo "$BASEPATH" | sed -e 's/ /%20/g'` ARGS="$@" From c3f8dab0d5dbcb306ef12386d43d16f07199c31b Mon Sep 17 00:00:00 2001 From: Bob Kerns Date: Tue, 11 Sep 2012 19:35:12 -0700 Subject: [PATCH 2/3] Make the tests work when run from other directories. --- jsdoc | 1 + 1 file changed, 1 insertion(+) diff --git a/jsdoc b/jsdoc index 9eb02813..2949cbd4 100755 --- a/jsdoc +++ b/jsdoc @@ -34,6 +34,7 @@ fi if test "$1" = "-T" then echo "Running Tests" + cd -P "$(dirname "$SOURCE")" java -classpath "${BASEPATH}/lib/js.jar" ${CMD} -opt -1 -modules "${URLPATH}/nodejs_modules" -modules "${URLPATH}/rhino_modules" -modules "${URLPATH}" "${BASEPATH}/jsdoc.js" $ARGS --dirname="${BASEPATH}/" else From 3bf586ab5f5e36c7f707e254950ce05438e8b061 Mon Sep 17 00:00:00 2001 From: Bob Kerns Date: Tue, 11 Sep 2012 19:38:50 -0700 Subject: [PATCH 3/3] Make the tests work under Cygwin Under Cygwin, we need to be a bit more aggressive with replacing \ with / to avoid \ in URIs internally. This shows up when running the tests with -T, but not when running files directly, for reasons I don't fully understand. This patch replaces the previous replacement of \ => / with one that happens earlier and applies to all references, not just the URIs we construct. Cygwin now passes jsdoc -T from any directory. --- jsdoc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jsdoc b/jsdoc index 2949cbd4..9c78cbc4 100755 --- a/jsdoc +++ b/jsdoc @@ -6,6 +6,7 @@ while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done # Get a Windows path under MinGW or Cygwin BASEPATH="$( cd -P "$( dirname "$SOURCE" )" && (pwd -W 2>/dev/null || cygpath -w $(pwd) 2>/dev/null || pwd))" if [ "${BASEPATH:0:1}" != "/" ] ; then + BASEPATH="${BASEPATH//\\//}" # We need a extra slash for URLs UBASEPATH="/$BASEPATH" else @@ -14,7 +15,7 @@ fi # for whatever reason, Rhino requires module paths to be valid URIs URLPATH="file://$UBASEPATH" -URLPATH=`echo "$URLPATH" | sed -e 's/ /%20/g' -e 's#\\\\#/#g'` +URLPATH=`echo "$URLPATH" | sed -e 's/ /%20/g'` ENCODEDBASEPATH=`echo "$BASEPATH" | sed -e 's/ /%20/g'` ARGS="$@"