Created
November 19, 2011 21:25
-
-
Save radar/1379381 to your computer and use it in GitHub Desktop.
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
#!/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