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

Commit

Permalink
* Pretty close now, I think...
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Hollensbe committed Jul 8, 2010
1 parent 5950155 commit 4cad931
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 96 deletions.
28 changes: 24 additions & 4 deletions lib/hanna/hanna.rb
Expand Up @@ -19,6 +19,7 @@ class RDoc::Generator::Hanna
CLASS_PAGE = 'page.haml' CLASS_PAGE = 'page.haml'
METHOD_LIST_PAGE = 'method_list.haml' METHOD_LIST_PAGE = 'method_list.haml'
FILE_PAGE = CLASS_PAGE FILE_PAGE = CLASS_PAGE
SECTIONS_PAGE = 'sections.haml'


FILE_INDEX = 'file_index.haml' FILE_INDEX = 'file_index.haml'
CLASS_INDEX = 'class_index.haml' CLASS_INDEX = 'class_index.haml'
Expand Down Expand Up @@ -109,6 +110,7 @@ def generate_index(outfile, templfile, index_name, values)


def generate_file_files def generate_file_files
file_page = haml_file(templjoin(FILE_PAGE)) file_page = haml_file(templjoin(FILE_PAGE))
method_list_page = haml_file(templjoin(METHOD_LIST_PAGE))


# FIXME non-Ruby files # FIXME non-Ruby files
@files.each do |file| @files.each do |file|
Expand All @@ -125,7 +127,11 @@ def generate_file_files
:description => file.description :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 # FIXME XXX sanity check
dir = path.dirname dir = path.dirname
Expand All @@ -138,8 +144,9 @@ def generate_file_files
end end


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)) method_list_page = haml_file(templjoin(METHOD_LIST_PAGE))
sections_page = haml_file(templjoin(SECTIONS_PAGE))
# FIXME refactor # FIXME refactor


@classes.each do |klass| @classes.each do |klass|
Expand All @@ -153,10 +160,23 @@ def generate_class_files
:classmod => klass.type, :classmod => klass.type,
:title => klass.full_name, :title => klass.full_name,
:list_title => nil, :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 # FIXME XXX sanity check
dir = outfile.dirname dir = outfile.dirname
Expand Down
20 changes: 9 additions & 11 deletions lib/hanna/template_files/method_list.haml
Expand Up @@ -2,11 +2,9 @@
- unless methods.empty? - unless methods.empty?
#method-list #method-list
%h2 Methods %h2 Methods
- types = %w[attr_reader attr_writer attr_accessor class instance] - %w[attr attr_accessor attr_reader attr_writer class instance].each do |type|
- visibilities = [:public, :protected, :private] - RDoc::Context::VISIBILITIES.each do |vis|
- types.each do |type| - list = methods.select { |x| x.visibility == vis && x.type == type.to_s }
- visibilities.each do |vis|
- list = methods.select { |x| x.visibility == vis && x.type == type }
- unless list.empty? - unless list.empty?
- type_result = "" - type_result = ""
- if type =~ /^attr_/ - if type =~ /^attr_/
Expand All @@ -27,12 +25,12 @@


- if values[:entry].requires or values[:entry].sections or values[:entry].includes - if values[:entry].requires or values[:entry].sections or values[:entry].includes
#context #context
- if values[:entry].requires - unless values[:entry].requires.empty?
#requires #requires
%h2 Required files %h2 Required files
%ol %ol
- values[:entry].requires do |req| - values[:entry].requires.each do |req|
%li= link_to req, req %li= req.name


-# FIXME reenable -# FIXME reenable
-#- if values[:entry].sections -#- if values[:entry].sections
Expand All @@ -42,10 +40,10 @@
-#- values[:entry].sections.each do |item| -#- values[:entry].sections.each do |item|
-#%li= link_to values[:secname], values[:href] -#%li= link_to values[:secname], values[:href]
- if values[:entry].includes - unless values[:entry].includes.empty?
#includes #includes
%h2 Included modules %h2 Included modules
%ol %ol
- values[:entry].includes do |inc| - values[:entry].includes.each do |inc|
%li= link_to inc, inc %li= inc.name


162 changes: 81 additions & 81 deletions lib/hanna/template_files/sections.haml
@@ -1,83 +1,83 @@
- for section in values[:sections] - section = values[:section]
#section #section
- if section[:sectitle] - if section[:sectitle]
%h2= link_to section[:sectitle], section[:secsequence] %h2= link_to section[:sectitle], section[:secsequence]
- if section[:seccomment] - if section[:seccomment]
.section-comment= section[:seccomment] .section-comment= section[:seccomment]


- if section[:classlist] - if section[:classlist] =~ /<li>/
#class-list #class-list
%h2 Classes and Modules %h2 Classes and Modules
= section[:classlist] = section[:classlist]


- if section[:constants] - unless section[:constants].empty?
#constants-list #constants-list
%h2 Constants %h2 Constants
.name-list .name-list
%table{ :summary => "Constants" } %table{ :summary => "Constants" }
- for const in section[: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 %tr.top-aligned-row.context-row
%td.context-item-name= const[:name] %td &nbsp;
%td = %td.context-item-desc{ :colspan => "2" }
%td.context-item-value= const[:value] = alia.description
- if const[:desc] then
%td &nbsp; - unless section[:attributes].empty?
%td.context-item-desc= const[:desc] #attribute-list

%h2.section-bar Attributes
- if section[:aliases] .name-list
#aliases-list %table
%h2 External Aliases - section[:attributes].each do |attrib|
.name-list %tr.top-aligned-row.context-row
%table{ :summary => "External aliases" } %td.context-item-name= attrib.name
- for alia in section[:aliases] %td.context-item-value= attrib.rw ? "[#{attrib.rw}]" : '&nbsp;'
%tr.top-aligned-row.context-row %td.context-item-desc~ sanitize_code_blocks(attrib.description)
%td.context-item-name= alia[:old_name]
%td -&gt; - unless section[:method_list].empty?
%td.context-item-value= alia[:new_name] #methods
- if alia[:desc] then - section[:method_list].group_by { |x| [x.visibility, x.type].map(&:to_s).map(&:capitalize).join(" ") }.each do |type, list|
%tr.top-aligned-row.context-row - unless list.empty?
%td &nbsp; %h2== #{type} methods
%td.context-item-desc{ :colspan => "2" }
= alia[:desc] - list.each do |method|

.method{ :id => "method-#{method.aref}", :class => "#{type.gsub(/\s+/, '-')}".downcase }
- if section[:attributes] %a{ :name => method.aref }
#attribute-list .synopsis
%h2.section-bar Attributes - method_html = capture_haml do
.name-list - if method.call_seq
%table %span.name= method.call_seq
- 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
- else - else
= method_html %span.name= method.name
- if method[:m_desc] %span.arguments= method.params
.description -#- if method[:codeurl]
~ sanitize_code_blocks method[:m_desc] -#%a.method-signature{ :href => method[:codeurl], :onclick => "popupCode(this.href); return false", :target => "Code" }
- if method[:sourcecode] -#= method_html
.source -#- else
- name = "#{method[:aref]}-source" = method_html
%a.source-toggle{ :href => "#", :onclick => "toggleCode('#{name}'); return false" } - if method.description
[show source] .description
~ "<pre id='#{name}'>#{method[:sourcecode]}</pre>" ~ 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.