Skip to content

Instantly share code, notes, and snippets.

@skahack
Created May 14, 2012 21:25
Show Gist options
  • Save skahack/2697258 to your computer and use it in GitHub Desktop.
Save skahack/2697258 to your computer and use it in GitHub Desktop.
Haskell installed packages DocSet for Dash
require 'cgi'
require 'nokogiri'
xml = <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<Tokens version="1.0">
EOF
doc = nil
open 'Documents/doc/index.html' do |f|
doc = Nokogiri::HTML(f)
end
doc.css('li span.module a').each do |t|
href = t['href'].scan(/doc.*/)[0]
xml << "<File path=\"#{href}\"><Token><TokenIdentifier>//apple_ref/java/cl/#{t.content}</TokenIdentifier></Token></File>\n"
end
open 'Documents/doc/doc-index-All.html' do |f|
doc = Nokogiri::HTML f
src = ''
doc.css('tr').each do |tr|
if tr.css('td.src').first != nil
src = tr.css('td.src').first.content
elsif tr.css('td.module a').first != nil
t = tr.css('td.module a').first
href = t['href'].scan(/doc.*/)[0]
content = CGI.escapeHTML("#{t.content}.#{src}")
xml << "<File path=\"#{href}\"><Token><TokenIdentifier>//apple_ref/java/clm/#{content}</TokenIdentifier></Token></File>\n"
end
end
end
xml << '</Tokens>'
open 'Tokens.xml', 'w' do |f|
f.write xml
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment