Skip to content

Instantly share code, notes, and snippets.

@radar
Created November 19, 2011 21:25
Show Gist options
  • Save radar/1379381 to your computer and use it in GitHub Desktop.
Save radar/1379381 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rdoc/rdoc'
require 'nokogiri'
class Sume
RDoc::RDoc.add_generator self
def initialize(options)
super()
end
def class_dir
"http://radar.github.com/#!/search/"
end
def generate(toplevels)
modules = toplevels.map(&:modules).flatten.uniq
classes = toplevels.map(&:classes).flatten.uniq
generate_module_index(modules)
generate_class_index(classes)
end
def generate_module_index(modules)
end
def generate_class_index(classes)
classes.each do |klass|
generate_class_method_index(klass)
generate_instance_method_index(klass)
# p klass.path.gsub(/\.html$/,'')
# p klass.method(:description).source_location
# p fix_links(klass.description)
end
end
def generate_class_method_index(klass)
end
def generate_instance_method_index(klass)
klass.instance_method_list.each do |method|
fix_links(method.description)
end
end
private
def fix_links(description)
html = Nokogiri::HTML::DocumentFragment.parse(description)
html.css("a").each do |a|
a["href"] = a["href"].gsub(/^\.?/, "#search/")
a["href"] = a["href"].gsub(/.html$/, "")
end
html.to_html
end
end
r = RDoc::RDoc.new
r.document(['--format=sume', '--markup'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment