Permalink
Browse files

* attribute names now show up in the method index (+ search)

* A little cleanup
  • Loading branch information...
1 parent 1ddffeb commit 95d9975dd8bc1cd039346737b65d813b1ec906ae Erik Hollensbe committed Jul 12, 2010
Showing with 14 additions and 13 deletions.
  1. +11 −11 lib/hanna/hanna.rb
  2. +3 −2 lib/hanna/template_files/method_index.haml
View
22 lib/hanna/hanna.rb
@@ -56,18 +56,18 @@ def initialize( options )
@files = nil
@classes = nil
@methods = nil
- #@modsort = nil
+ @attributes = nil
@basedir = Pathname.pwd.expand_path
end
def generate( top_levels )
@outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir )
- @files = top_levels.sort
- @classes = RDoc::TopLevel.all_classes_and_modules.sort
- @methods = @classes.map { |m| m.method_list }.flatten.sort
- #@modsort = get_sorted_module_list( @classes )
+ @files = top_levels.sort
+ @classes = RDoc::TopLevel.all_classes_and_modules.sort
+ @methods = @classes.map(&:method_list).flatten.sort
+ @attributes = @classes.map(&:attributes).flatten.sort
# Now actually write the output
write_static_files
@@ -95,9 +95,9 @@ def generate_indexes
@main_page_uri = @files.find { |f| f.name == @options.main_page }.path rescue ''
File.open(outjoin(INDEX_OUT), 'w') { |f| f << haml_file(templjoin(INDEX_PAGE)).to_html(binding) }
- generate_index(FILE_INDEX_OUT, FILE_INDEX, 'File', { :files => @files})
- generate_index(CLASS_INDEX_OUT, CLASS_INDEX, 'Class', { :classes => @classes })
- generate_index(METHOD_INDEX_OUT, METHOD_INDEX, 'Method', { :methods => @methods })
+ generate_index(FILE_INDEX_OUT, FILE_INDEX, 'File', { :files => @files})
+ generate_index(CLASS_INDEX_OUT, CLASS_INDEX, 'Class', { :classes => @classes })
+ generate_index(METHOD_INDEX_OUT, METHOD_INDEX, 'Method', { :methods => @methods, :attributes => @attributes })
end
def generate_index(outfile, templfile, index_name, values)
@@ -266,7 +266,7 @@ def build_javascript_search_index(entries)
method_name = entry.name
module_name = entry.parent_name
# FIXME link
- html = link_to_method(entry, [classfile(entry.parent), entry.aref].join('#'))
+ html = link_to_method(entry, [classfile(entry.parent), (entry.aref rescue "method-#{entry.html_name}")].join('#'))
result << " { method: '#{method_name.downcase}', " +
"module: '#{module_name.downcase}', " +
"html: '#{html}' },\n"
@@ -289,8 +289,8 @@ def link_to(text, url = nil, classname = nil)
# +method_text+ is in the form of "ago (ActiveSupport::TimeWithZone)".
def link_to_method(entry, url = nil, classname = nil)
- method_name = entry.pretty_name
- module_name = entry.parent_name
+ method_name = entry.pretty_name rescue entry.name
+ module_name = entry.parent_name rescue entry.name
link_to %Q(<span class="method_name">#{h method_name}</span> <span class="module_name">(#{h module_name})</span>), url, classname
end
View
5 lib/hanna/template_files/method_index.haml
@@ -2,13 +2,14 @@
%script{:type => 'text/javascript'}
= File.read(File.join(@templatedir, "prototype-1.6.0.3.js"))
- = build_javascript_search_index(values[:methods])
+ = build_javascript_search_index(values[:methods] + values[:attributes])
= File.read(File.join(@templatedir, "method_search.js"))
%form{:onsubmit => 'return performSearch()'}
%input{:type => 'text', :id => 'search', :class => 'untouched', :value => 'Enter search terms...'}
%ol#search-results{ :class => 'methods', :style => 'display: none' }
%ol#index-entries{ :class => 'methods' }
+ - values[:attributes].each do |entry|
+ %li= link_to_method entry, [classfile(entry.parent), "method-#{entry.html_name}"].join('#')
- values[:methods].each do |entry|
- -# FIXME link
%li= link_to_method entry, [classfile(entry.parent), entry.aref].join('#')

0 comments on commit 95d9975

Please sign in to comment.