In Files
Parent
Class Index
- WebRI
- WebRI::Blackfish
- WebRI::Component
- WebRI::Generator
- WebRI::GeneratorOne
- WebRI::GitHub
- WebRI::Heirarchy
- WebRI::Highlight
- WebRI::Icons
- WebRI::JSONFile
- WebRI::Longfish
- WebRI::Metadata
- WebRI::Newfish
- WebRI::Oldfish
- WebRI::Onefish
- WebRI::Prettify
- WebRI::Redfish
- WebRI::RiService
- WebRI::Search
- WebRI::Search::FilesTree
- WebRI::Server
- WebRI::Subversion
- WebRI::Template
- WebRI::TimeDelta
- WebRI::Twofish
- RDoc
- RDoc::AnyMethod
- RDoc::ClassModule
- RDoc::Options
- RDoc::Parser
- RDoc::Parser::C
- RDoc::TopLevel
- Syckle
- Syckle::Plugins
- Syckle::Plugins::WebRI
- Object
- OpEsc
Public Class Methods
Public Instance Methods
autolink(html, entry)
click to toggle source
Search for certain patterns within the HTML and subs in hyperlinks.
Eg.
<h2>Instance methods:</h2> current_content, directory, generate, generate_recurse, generate_tree
# File lib/webri/server/server.rb, line 168 def autolink(html, entry) link = entry.gsub('::','/') re = Regexp.new(Regexp.escape(entry), Regexp::MULTILINE) if md = re.match(html) title = %[<a class="link title" href="javascript: lookup_static(this, '#{link}.html');">#{md[0]}</a>] html[md.begin(0)...md.end(0)] = title end # class methods re = Regexp.new(Regexp.escape("<h2>Class methods:</h2>") + "(.*?)" + Regexp.escape("<"), Regexp::MULTILINE) if md = re.match(html) meths = md[1].split(",").map{|m| m.strip} meths = meths.map{|m| %[<a class="link" href="javascript: lookup_static(this, '#{link}/c-#{m}.html');">#{m}</a>] } html[md.begin(1)...md.end(1)] = meths.join(", ") end # instance methods re = Regexp.new(Regexp.escape("<h2>Instance methods:</h2>") + "(.*?)" + Regexp.escape("<"), Regexp::MULTILINE) if md = re.match(html) meths = md[1].split(",").map{|m| m.strip} meths = meths.map{|m| %[<a class="link" href="javascript: lookup_static(this, '#{link}/i-#{m}.html');">#{m}</a>] } html[md.begin(1)...md.end(1)] = meths.join(", ") end return html end
current_content()
click to toggle source
# File lib/webri/server/server.rb, line 334 def current_content @current_content end
directory()
click to toggle source
# File lib/webri/server/server.rb, line 41 def directory @directory ||= File.dirname(__FILE__) end
esc(text)
click to toggle source
# File lib/webri/server/server.rb, line 339 def esc(text) OpEsc.escape(text.to_s) #CGI.escape(text.to_s).gsub('-','%2D') end
generate_tree(entry)
click to toggle source
generate html tree
# File lib/webri/server/server.rb, line 91 def generate_tree(entry) markup = [] if entry.root? markup << %[<div class="root">] else path = WebRI.entry_to_path(entry.full_name) markup << %[ <li class="trigger"> <img src="assets/img/class.png" onClick="showBranch(this);"/> <span class="link" onClick="lookup_static(this, '#{path}');">#{entry.name}</span> ] markup << %[<div class="branch">] end markup << %[<ul>] cmethods = entry.class_methods.map{ |x| x.to_s }.sort cmethods.each do |method| path = WebRI.entry_to_path(entry.full_name + ".#{method}") markup << %[ <li class="meta_leaf"> <span class="link" onClick="lookup_static(this, '#{path}');">#{method}</span> </li> ] end imethods = entry.instance_methods.map{ |x| x.to_s }.sort imethods.each do |method| path = WebRI.entry_to_path(entry.full_name + "##{method}") markup << %[ <li class="leaf"> <span class="link" onClick="lookup_static(this, '#{path}');">#{method}</span> </li> ] end entry.subspaces.to_a.sort{ |a,b| a[0].to_s <=> b[0].to_s }.each do |(name, subspace)| #subspaces.each do |name, subspace| markup << generate_tree(subspace) #subspace.to_html end markup << %[</ul>] if entry.root? markup << %[</div>] else markup << %[</div>] markup << %[</li>] end return markup.join("\n") end
heirarchy()
click to toggle source
# File lib/webri/server/server.rb, line 46 def heirarchy @heirarchy ||=( ns = Heirarchy.new(nil) service.names.each do |m| if m.index('#') type = :instance space, method = m.split('#') spaces = space.split('::').collect{|s| s.to_sym } method = method.to_sym elsif m.index('::') type = :class spaces = m.split('::').collect{|s| s.to_sym } if spaces.last.to_s =~ /^[a-z]/ method = spaces.pop else next # what to do about class/module ? end else next # what to do abot class/module ? end memo = ns spaces.each do |space| memo[space] ||= Heirarchy.new(space, memo) memo = memo[space] end if type == :class memo.class_methods << method else memo.instance_methods << method end end ns ) end
index()
click to toggle source
# File lib/webri/server/server.rb, line 226 def index render(template('index')) end
lookup(path)
click to toggle source
# File lib/webri/server/server.rb, line 144 def lookup(path) entry = WebRI.path_to_entry(path) if entry html = service.info(entry) html = autolink(html, entry) #term = AnsiSys::Terminal.new.echo(ansi) #html = term.render(:html) #=> HTML fragment #html = ERB::Util.html_escape(html) html = "#{html}<br/><br/>" else html = "<h1>ERROR</h1>" end return html end
render(source)
click to toggle source
# File lib/webri/server/server.rb, line 210 def render(source) template = ERB.new(source) template.result(binding) end
template(name)
click to toggle source
# File lib/webri/server/server.rb, line 197 def template(name) @templates[name] ||= File.read(File.join(directory, 'templates', name + '.html')) end
Disabled; run with --debug to generate this.