Created
June 23, 2009 20:26
-
-
Save Voker57/134818 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/ruby | |
# Hackage [http://hackage.haskell.org] documentation downloader | |
# Fetches documentation for installed only (or all available) Cabal packages in current directory | |
# Use --all to download docs for all packages | |
# Requires wget and cabal to be installed | |
# by Voker57 <[email protected]> | |
# | |
# Public domain | |
require 'fileutils' | |
installed = (ARGV.include? "--all") ? "" : "--installed" | |
packages = `cabal list #{installed} --simple-output`.split($/).map{|v| v.split(/\s+/)} | |
packages.each do |pk| | |
print "Fetching docs for #{pk[0]}, version #{pk[1]}..." | |
STDOUT.flush | |
dir = "#{pk[0]}/#{pk[1]}" | |
if File.exists? dir | |
puts "skipped." | |
else | |
FileUtils.mkdir_p dir | |
`wget -c --mirror -np -k -nH --cut-dirs=6 -A html,png,gif,css,js -a log.txt -P #{dir} http://hackage.haskell.org/packages/archive/#{pk[0]}/#{pk[1]}/doc/html/` | |
if $?.exitstatus == 0 | |
puts "done." | |
File.delete "log.txt" | |
else | |
puts "error #{$?.exitstatus}, see log.txt for details" | |
FileUtils.rm_r dir if File.exists? dir | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment