Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
* Method list is showing up.
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Hollensbe committed Jul 8, 2010
1 parent 258c1f9 commit 5950155
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 25 deletions.
4 changes: 3 additions & 1 deletion lib/hanna/hanna.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class RDoc::Generator::Hanna


INDEX_PAGE = 'index.haml' INDEX_PAGE = 'index.haml'
CLASS_PAGE = 'page.haml' CLASS_PAGE = 'page.haml'
METHOD_LIST_PAGE = 'method_list.haml'
FILE_PAGE = CLASS_PAGE FILE_PAGE = CLASS_PAGE


FILE_INDEX = 'file_index.haml' FILE_INDEX = 'file_index.haml'
Expand Down Expand Up @@ -138,6 +139,7 @@ def generate_file_files


def generate_class_files def generate_class_files
class_page = haml_file(templjoin(CLASS_PAGE)) class_page = haml_file(templjoin(CLASS_PAGE))
method_list_page = haml_file(templjoin(METHOD_LIST_PAGE))
# FIXME refactor # FIXME refactor


@classes.each do |klass| @classes.each do |klass|
Expand All @@ -154,7 +156,7 @@ def generate_class_files
:description => klass.description :description => klass.description
} }


result = with_layout(values) { class_page.to_html(binding, :values => values) { '' } } result = with_layout(values) { class_page.to_html(binding, :values => values) { method_list_page.to_html(binding, :values => values) } }


# FIXME XXX sanity check # FIXME XXX sanity check
dir = outfile.dirname dir = outfile.dirname
Expand Down
62 changes: 38 additions & 24 deletions lib/hanna/template_files/method_list.haml
Original file line number Original file line Diff line number Diff line change
@@ -1,37 +1,51 @@
- methods = methods_from_sections values[:sections] - methods = values[:entry].method_list + values[:entry].attributes
- unless methods.empty? - unless methods.empty?
#method-list #method-list
%h2 Methods %h2 Methods
- for type in ['public class', 'protected class', 'public instance', 'protected instance'] - types = %w[attr_reader attr_writer attr_accessor class instance]
- unless (list = methods[type]).empty? - visibilities = [:public, :protected, :private]
%h3= type - types.each do |type|
%ol - visibilities.each do |vis|
- for method in list - list = methods.select { |x| x.visibility == vis && x.type == type }
- if method[:name].to_s.empty? && method[:callseq] - unless list.empty?
%li= link_to method[:callseq].gsub(/<br\s*\/?>/, "").split(/[\r\n]+/).map{ |s| s.split(/([({]+|\[\{|\s+(#?=>|&rarr;)\s+)/).first.sub(/^[A-Za-z0-9_:]+\./, "").sub(/\s+=\s+.*/, "=").strip }.uniq.join("<br />\n"), '#' + method[:aref] - type_result = ""
- else - if type =~ /^attr_/
%li= link_to method[:name], '#' + method[:aref] - type_result += type.sub(/^attr_/, '').capitalize
- else
- type_result += type.capitalize
- type_result = "#{vis.to_s.capitalize} #{type_result}"
%h3= type_result
%ol
- list.each do |method|
- if method.respond_to?(:aref)
- if method.name.to_s.empty? && method.call_seq
%li= link_to method.call_seq.gsub(/<br\s*\/?>/, "").split(/[\r\n]+/).map{ |s| s.split(/([({]+|\[\{|\s+(#?=>|&rarr;)\s+)/).first.sub(/^[A-Za-z0-9_:]+\./, "").sub(/\s+=\s+.*/, "=").strip }.uniq.join("<br />\n"), '#' + method.aref
- else
%li= link_to method.name, '#' + method.aref
- else
%li= method.name


- if values[:requires] or values[:toc] or values[:includes] - if values[:entry].requires or values[:entry].sections or values[:entry].includes
#context #context
- if values[:requires] - if values[:entry].requires
#requires #requires
%h2 Required files %h2 Required files
%ol %ol
- for req in values[:requires] - values[:entry].requires do |req|
%li= link_to req[:name], req[:aref] %li= link_to req, req


- if values[:toc] -# FIXME reenable
#contents -#- if values[:entry].sections
%h2 Contents -##contents
%ol -#%h2 Contents
- for item in values[:toc] -#%ol
%li= link_to values[:secname], values[:href] -#- values[:entry].sections.each do |item|
-#%li= link_to values[:secname], values[:href]
- if values[:includes] - if values[:entry].includes
#includes #includes
%h2 Included modules %h2 Included modules
%ol %ol
- for inc in values[:includes] - values[:entry].includes do |inc|
%li= link_to inc[:name], inc[:aref] %li= link_to inc, inc


0 comments on commit 5950155

Please sign in to comment.