Skip to content

Instantly share code, notes, and snippets.

@samskivert
Created March 5, 2014 19:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samskivert/9374390 to your computer and use it in GitHub Desktop.
Save samskivert/9374390 to your computer and use it in GitHub Desktop.
Bash script to remove redirect JS crap from scaladoc
#!/bin/sh
#
# Trims out the bullshit "redirect me to the top-level page" Javascript that scaladoc
# jams into every fucking documentation page. Fucking fuckers.
if [ -z "$1" ]; then
echo "Usage: $0 somedoc.jar"
exit 255
fi
OLDCWD=`pwd`
rm -rf /tmp/ufscaladoc
mkdir /tmp/ufscaladoc
cd /tmp/ufscaladoc
jar xf $1
for file in `find scala -name '*.html'`; do
LINE12=`sed -n '12,12p' $file | sed 's: ::g'`
if [ "$LINE12" = '<scripttype="text/javascript">' ]; then
echo "Trimming $file..."
awk 'NR < 12 || NR > 22' $file > $file.new
mv $file.new $file
fi
done
jar cf $OLDCWD/unfucked.jar *
cd $OLDCWD
rm -rf /tmp/ufscaladoc
echo "If nothing choked:"
echo "mv unfucked.jar $1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment