Created
March 5, 2014 19:14
-
-
Save samskivert/9374390 to your computer and use it in GitHub Desktop.
Bash script to remove redirect JS crap from scaladoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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