Skip to content

Instantly share code, notes, and snippets.

@kohsuke
Created July 21, 2016 20:53
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 kohsuke/04d1a1bf40ec79ccea23fbdca7d133b5 to your computer and use it in GitHub Desktop.
Save kohsuke/04d1a1bf40ec79ccea23fbdca7d133b5 to your computer and use it in GitHub Desktop.
javadocReverseIndex.groovy
#!/usr/bin/env groovy
/*
Generate index from short/full class name to the javadoc page, in the form of .htaccess.
This serves http://hudson-ci.org/javadoc/byShortName/
Push it as scp .htaccess hudson-ci.org:~/www/jenkins-ci.org/javadoc/byShortName
*/
index = new TreeMap();
base = new File("./target/site/apidocs");
base.eachFileRecurse { File f ->
if(f.path.contains("-")) return; // non class files produced by javadoc
if(!f.path.endsWith(".html")) return; // directories and others
tail = f.path.substring(base.path.length()+1);
shortClassName = f.name.substring(0,f.name.length()-5); // cut off ".html"
fullClassName = tail.substring(0,tail.length()-5).replace('/','.');
index[shortClassName] = tail;
index[fullClassName] = tail;
}
index.each { k,v ->
println "Redirect 302 /byShortName/${k} http://javadoc.jenkins-ci.org/?${v}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment