Permalink
Browse files

* Pretty close now, I think...

  • Loading branch information...
1 parent 5950155 commit 4cad931ac5aef931279ae140cf8e5b93b60c9588 Erik Hollensbe committed Jul 8, 2010
Showing with 114 additions and 96 deletions.
  1. +24 −4 lib/hanna/hanna.rb
  2. +9 −11 lib/hanna/template_files/method_list.haml
  3. +81 −81 lib/hanna/template_files/sections.haml
View
@@ -19,6 +19,7 @@ class RDoc::Generator::Hanna
CLASS_PAGE = 'page.haml'
METHOD_LIST_PAGE = 'method_list.haml'
FILE_PAGE = CLASS_PAGE
+ SECTIONS_PAGE = 'sections.haml'
FILE_INDEX = 'file_index.haml'
CLASS_INDEX = 'class_index.haml'
@@ -109,6 +110,7 @@ def generate_index(outfile, templfile, index_name, values)
def generate_file_files
file_page = haml_file(templjoin(FILE_PAGE))
+ method_list_page = haml_file(templjoin(METHOD_LIST_PAGE))
# FIXME non-Ruby files
@files.each do |file|
@@ -125,7 +127,11 @@ def generate_file_files
:description => file.description
}
- result = with_layout(values) { file_page.to_html(binding, :values => values) { '' } }
+ result = with_layout(values) do
+ file_page.to_html(binding, :values => values) do
+ method_list_page.to_html(binding, values)
+ end
+ end
# FIXME XXX sanity check
dir = path.dirname
@@ -138,8 +144,9 @@ def generate_file_files
end
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))
+ sections_page = haml_file(templjoin(SECTIONS_PAGE))
# FIXME refactor
@classes.each do |klass|
@@ -153,10 +160,23 @@ def generate_class_files
:classmod => klass.type,
:title => klass.full_name,
:list_title => nil,
- :description => klass.description
+ :description => klass.description,
+ :section => {
+ # FIXME linkify
+ :classlist => '<ol>' + klass.classes_and_modules.inject('') { |x,y| x << '<li>' + y.name + '</li>' } + '</ol>',
+ :constants => klass.constants,
+ :aliases => klass.aliases,
+ :attributes => klass.attributes,
+ :method_list => klass.method_list
+ }
}
- result = with_layout(values) { class_page.to_html(binding, :values => values) { method_list_page.to_html(binding, :values => values) } }
+ result = with_layout(values) do
+ class_page.to_html(binding, :values => values) do
+ method_list_page.to_html(binding, :values => values) +
+ sections_page.to_html(binding, :values => values)
+ end
+ end
# FIXME XXX sanity check
dir = outfile.dirname
@@ -2,11 +2,9 @@
- unless methods.empty?
#method-list
%h2 Methods
- - types = %w[attr_reader attr_writer attr_accessor class instance]
- - visibilities = [:public, :protected, :private]
- - types.each do |type|
- - visibilities.each do |vis|
- - list = methods.select { |x| x.visibility == vis && x.type == type }
+ - %w[attr attr_accessor attr_reader attr_writer class instance].each do |type|
+ - RDoc::Context::VISIBILITIES.each do |vis|
+ - list = methods.select { |x| x.visibility == vis && x.type == type.to_s }
- unless list.empty?
- type_result = ""
- if type =~ /^attr_/
@@ -27,12 +25,12 @@
- if values[:entry].requires or values[:entry].sections or values[:entry].includes
#context
- - if values[:entry].requires
+ - unless values[:entry].requires.empty?
#requires
%h2 Required files
%ol
- - values[:entry].requires do |req|
- %li= link_to req, req
+ - values[:entry].requires.each do |req|
+ %li= req.name
-# FIXME reenable
-#- if values[:entry].sections
@@ -42,10 +40,10 @@
-#- values[:entry].sections.each do |item|
-#%li= link_to values[:secname], values[:href]
- - if values[:entry].includes
+ - unless values[:entry].includes.empty?
#includes
%h2 Included modules
%ol
- - values[:entry].includes do |inc|
- %li= link_to inc, inc
+ - values[:entry].includes.each do |inc|
+ %li= inc.name
@@ -1,83 +1,83 @@
-- for section in values[:sections]
- #section
- - if section[:sectitle]
- %h2= link_to section[:sectitle], section[:secsequence]
- - if section[:seccomment]
- .section-comment= section[:seccomment]
-
- - if section[:classlist]
- #class-list
- %h2 Classes and Modules
- = section[:classlist]
-
- - if section[:constants]
- #constants-list
- %h2 Constants
- .name-list
- %table{ :summary => "Constants" }
- - for const in section[:constants]
+- section = values[:section]
+#section
+ - if section[:sectitle]
+ %h2= link_to section[:sectitle], section[:secsequence]
+ - if section[:seccomment]
+ .section-comment= section[:seccomment]
+
+ - if section[:classlist] =~ /<li>/
+ #class-list
+ %h2 Classes and Modules
+ = section[:classlist]
+
+ - unless section[:constants].empty?
+ #constants-list
+ %h2 Constants
+ .name-list
+ %table{ :summary => "Constants" }
+ - section[:constants].each do |const|
+ %tr.top-aligned-row.context-row
+ %td.context-item-name= const.name
+ %td =
+ %td.context-item-value= const.value
+ - if const.description then
+ %td &nbsp;
+ %td.context-item-desc= const.description
+
+ - unless section[:aliases].empty?
+ #aliases-list
+ %h2 External Aliases
+ .name-list
+ %table{ :summary => "External aliases" }
+ - section[:aliases].each do |alia|
+ %tr.top-aligned-row.context-row
+ %td.context-item-name= alia.old_name
+ %td -&gt;
+ %td.context-item-value= alia.new_name
+ - if alia[:desc] then
%tr.top-aligned-row.context-row
- %td.context-item-name= const[:name]
- %td =
- %td.context-item-value= const[:value]
- - if const[:desc] then
- %td &nbsp;
- %td.context-item-desc= const[:desc]
-
- - if section[:aliases]
- #aliases-list
- %h2 External Aliases
- .name-list
- %table{ :summary => "External aliases" }
- - for alia in section[:aliases]
- %tr.top-aligned-row.context-row
- %td.context-item-name= alia[:old_name]
- %td -&gt;
- %td.context-item-value= alia[:new_name]
- - if alia[:desc] then
- %tr.top-aligned-row.context-row
- %td &nbsp;
- %td.context-item-desc{ :colspan => "2" }
- = alia[:desc]
-
- - if section[:attributes]
- #attribute-list
- %h2.section-bar Attributes
- .name-list
- %table
- - for attr in section[:attributes]
- %tr.top-aligned-row.context-row
- %td.context-item-name= attr[:name]
- %td.context-item-value= attr[:rw] ? "[#{attr[:rw]}]" : '&nbsp;'
- %td.context-item-desc~ sanitize_code_blocks(attr[:a_desc])
-
- - if section[:method_list]
- #methods
- - for list in section[:method_list]
- - if list[:methods] then
- %h2== #{list[:type]} #{list[:category].downcase} methods
-
- - for method in list[:methods]
- .method{ :id => "method-#{method[:aref]}", :class => "#{list[:type]}-#{list[:category]}".downcase }
- %a{ :name => method[:aref] }
- .synopsis
- - method_html = capture_haml do
- - if method[:callseq]
- %span.name= method[:callseq]
- - else
- %span.name= method[:name]
- %span.arguments= method[:params]
- - if method[:codeurl]
- %a.method-signature{ :href => method[:codeurl], :onclick => "popupCode(this.href); return false", :target => "Code" }
- = method_html
+ %td &nbsp;
+ %td.context-item-desc{ :colspan => "2" }
+ = alia.description
+
+ - unless section[:attributes].empty?
+ #attribute-list
+ %h2.section-bar Attributes
+ .name-list
+ %table
+ - section[:attributes].each do |attrib|
+ %tr.top-aligned-row.context-row
+ %td.context-item-name= attrib.name
+ %td.context-item-value= attrib.rw ? "[#{attrib.rw}]" : '&nbsp;'
+ %td.context-item-desc~ sanitize_code_blocks(attrib.description)
+
+ - unless section[:method_list].empty?
+ #methods
+ - section[:method_list].group_by { |x| [x.visibility, x.type].map(&:to_s).map(&:capitalize).join(" ") }.each do |type, list|
+ - unless list.empty?
+ %h2== #{type} methods
+
+ - list.each do |method|
+ .method{ :id => "method-#{method.aref}", :class => "#{type.gsub(/\s+/, '-')}".downcase }
+ %a{ :name => method.aref }
+ .synopsis
+ - method_html = capture_haml do
+ - if method.call_seq
+ %span.name= method.call_seq
- else
- = method_html
- - if method[:m_desc]
- .description
- ~ sanitize_code_blocks method[:m_desc]
- - if method[:sourcecode]
- .source
- - name = "#{method[:aref]}-source"
- %a.source-toggle{ :href => "#", :onclick => "toggleCode('#{name}'); return false" }
- [show source]
- ~ "<pre id='#{name}'>#{method[:sourcecode]}</pre>"
+ %span.name= method.name
+ %span.arguments= method.params
+ -#- if method[:codeurl]
+ -#%a.method-signature{ :href => method[:codeurl], :onclick => "popupCode(this.href); return false", :target => "Code" }
+ -#= method_html
+ -#- else
+ = method_html
+ - if method.description
+ .description
+ ~ sanitize_code_blocks method.description
+ - if method.markup_code
+ .source
+ - name = "#{method.aref}-source"
+ %a.source-toggle{ :href => "#", :onclick => "toggleCode('#{name}'); return false" }
+ [show source]
+ ~ "<pre id='#{name}'>#{method.markup_code}</pre>"

0 comments on commit 4cad931

Please sign in to comment.