mislav-hanna 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown ADDED
@@ -0,0 +1,65 @@
1
+ # Hanna -- a better RDoc template
2
+
3
+ Hanna is an RDoc template that scales. It's implemented in Haml, making the
4
+ sources clean and readable. It's built with simplicity, beauty and ease of
5
+ browsing in mind.
6
+
7
+ Hanna is available from [GitHub][]:
8
+
9
+ gem install mislav-hanna
10
+
11
+ After that you have two options. You can use the command-line tool:
12
+
13
+ hanna -h
14
+
15
+ For repeated generation of API docs, it's better to set up a Rake task. Here is
16
+ an example for [will_paginate][]:
17
+
18
+ # instead of 'rake/rdoctask':
19
+ require 'hanna/rdoctask'
20
+
21
+ desc 'Generate RDoc documentation for the will_paginate plugin.'
22
+ Rake::RDocTask.new(:rdoc) do |rdoc|
23
+ rdoc.rdoc_files.include('README.rdoc', 'LICENSE', 'CHANGELOG').
24
+ include('lib/**/*.rb').
25
+ exclude('lib/will_paginate/named_scope*').
26
+ exclude('lib/will_paginate/array.rb').
27
+ exclude('lib/will_paginate/version.rb')
28
+
29
+ rdoc.main = "README.rdoc" # page to start on
30
+ rdoc.title = "will_paginate documentation"
31
+
32
+ rdoc.rdoc_dir = 'doc' # rdoc output folder
33
+ rdoc.options << '--webcvs=http://github.com/mislav/will_paginate/tree/master/'
34
+ end
35
+
36
+ Either way, it's the same as using RDoc.
37
+
38
+ Hanna was crafted by [Mislav][].
39
+
40
+ ## A work in progress
41
+
42
+ Hanna is far from done, but it is the first RDoc template that's actually
43
+ _maintainable_. First thing I have done is converted the original HTML
44
+ template to Haml and Sass, cleaning up and removing the (ridiculous amount of)
45
+ duplication.
46
+
47
+ Also, the template fragments are now in _separate files_. You would have
48
+ fainted if you seen how it was before. (It's really no wonder why there are no
49
+ other RDoc templates around ... save one: [Allison][].)
50
+
51
+ Ultimately, I'd like to lose the frameset. Currently that is far from possible
52
+ because the whole RDoc HTML Generator is built for frames. Still, that is my
53
+ goal.
54
+
55
+ ## You can help
56
+
57
+ Don't like something? Think you can design better? (You probably can.)
58
+
59
+ This is git. I welcome all submissions towards my goal.
60
+
61
+
62
+ [GitHub]: http://gems.github.com/ "GitHub gem source"
63
+ [will_paginate]: http://github.com/mislav/will_paginate
64
+ [Mislav]: http://mislav.caboo.se/ "Mislav Marohnić"
65
+ [Allison]: http://blog.evanweaver.com/files/doc/fauna/allison/ "A modern, pretty RDoc template"
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ desc %{Update ".manifest" with the latest list of project filenames. Respect .gitignore by excluding everything that git ignores. Update `files` and `test_files` arrays in "*.gemspec" file if it's present.}
2
+ task :manifest do
3
+ list = Dir['**/*'].sort
4
+ spec_file = Dir['*.gemspec'].first
5
+ list -= [spec_file] if spec_file
6
+
7
+ File.read('.gitignore').each_line do |glob|
8
+ glob = glob.chomp.sub(/^\//, '')
9
+ list -= Dir[glob]
10
+ list -= Dir["#{glob}/**/*"] if File.directory?(glob) and !File.symlink?(glob)
11
+ puts "excluding #{glob}"
12
+ end if File.exists?('.gitignore')
13
+
14
+ if spec_file
15
+ spec = File.read spec_file
16
+ spec.gsub! /^(\s* s.(test_)?files \s* = \s* )( \[ [^\]]* \] | %w\( [^)]* \) )/mx do
17
+ assignment = $1
18
+ bunch = $2 ? list.grep(/^test\//) : list
19
+ '%s%%w(%s)' % [assignment, bunch.join(' ')]
20
+ end
21
+
22
+ File.open(spec_file, 'w') {|f| f << spec }
23
+ end
24
+ File.open('.manifest', 'w') {|f| f << list.join("\n") }
25
+ end
data/bin/hanna ADDED
@@ -0,0 +1,41 @@
1
+ #!/usr/bin/ruby
2
+ if ARGV.size == 1 and ARGV.first == '-h'
3
+ puts <<-HELP
4
+ Hanna -- a better RDoc template
5
+ Sample usage:
6
+
7
+ hanna lib/**/*.rb
8
+
9
+ Hanna passes all arguments to RDoc. To find more about RDoc options,
10
+ see "rdoc -h". Default options:
11
+
12
+ -o doc --inline-source --charset=UTF-8
13
+
14
+ HELP
15
+ exit 0
16
+ end
17
+
18
+ require 'rubygems'
19
+ begin
20
+ gem 'rdoc', '~> 2.0.0'
21
+ rescue Gem::LoadError
22
+ $stderr.puts "Hanna requires the RDoc 2.0 gem."
23
+ exit 1
24
+ else
25
+ require 'rdoc/rdoc'
26
+ end
27
+
28
+ hanna_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
29
+ $:.unshift(hanna_dir) unless $:.include?(hanna_dir)
30
+
31
+ require 'hanna/rdoc_patch'
32
+
33
+ options = []
34
+
35
+ options << '-T' << 'hanna/hanna.rb'
36
+ options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
37
+ options << '--inline-source' << '--charset=UTF-8'
38
+
39
+ options.concat ARGV
40
+
41
+ RDoc::RDoc.new.document(options)
@@ -0,0 +1,55 @@
1
+ require 'haml'
2
+ require 'sass'
3
+ require 'rdoc/generator/html'
4
+ require 'hanna/template_page_patch'
5
+
6
+ # = A better RDoc HTML template
7
+ #
8
+ # Many different kinds of awesome.
9
+ #
10
+ # Author: Mislav Marohnić <mislav.marohnic@gmail.com>
11
+ # Based on the work of Michael Granger <ged@FaerieMUD.org>
12
+
13
+ module RDoc::Generator::HTML::Hanna
14
+ class << self
15
+ def dir
16
+ @dir ||= File.join File.dirname(__FILE__), 'template_files'
17
+ end
18
+
19
+ def read(*names)
20
+ extension = nil
21
+
22
+ content = names.map { |name|
23
+ if extension
24
+ name += '.' + extension
25
+ else
26
+ extension = name =~ /\.(\w+)$/ && $1
27
+ end
28
+ File.read File.join(dir, name)
29
+ }.join('')
30
+
31
+ case extension
32
+ when 'sass'
33
+ Sass::Engine.new(content)
34
+ when 'haml'
35
+ Haml::Engine.new(content)
36
+ else
37
+ content
38
+ end
39
+ end
40
+ end
41
+
42
+ STYLE = read('styles.sass')
43
+
44
+ CLASS_PAGE = read('page.haml')
45
+ FILE_PAGE = CLASS_PAGE
46
+ METHOD_LIST = read('method_list.haml', 'sections')
47
+
48
+ FR_INDEX_BODY = BODY = read('layout.haml')
49
+
50
+ FILE_INDEX = read('file_index.haml')
51
+ CLASS_INDEX = read('class_index.haml')
52
+ METHOD_INDEX = FILE_INDEX
53
+
54
+ INDEX = read('index.haml')
55
+ end
@@ -0,0 +1,22 @@
1
+ require 'rdoc/generator/html'
2
+
3
+ # RDoc 2.0.0 is inflexible in a way that it doesn't handle absolute paths for
4
+ # templates well. We fix that by catching an NameError in load_html_template:
5
+ RDoc::Generator::HTML.class_eval do
6
+ private
7
+ alias :load_html_template_original :load_html_template
8
+
9
+ def load_html_template
10
+ load_html_template_original
11
+ rescue NameError => e
12
+ raise unless e.message.index(@options.template.upcase)
13
+ name = File.basename(@options.template).sub(/\.rb$/, '')
14
+ klass = name.split('_').map{ |n| n.capitalize }.join
15
+ @options.template_class = @template = RDoc::Generator::HTML::const_get(klass)
16
+ end
17
+ end
18
+
19
+ # Don't ask. This works around a bug in Markup where it tries to call
20
+ # HTML.gen_url, but RDoc::Markup::ToHtml::HTML doesn't exist. (What were they
21
+ # thinking, I don't know.)
22
+ RDoc::Markup::ToHtml.const_set :HTML, RDoc::Generator
@@ -0,0 +1,46 @@
1
+ require 'rake'
2
+ require 'rake/rdoctask'
3
+
4
+ Rake::RDocTask.class_eval do
5
+ # don't allow it
6
+ undef :external=
7
+
8
+ # Create the tasks defined by this task lib.
9
+ def define
10
+ unless @template and @template != 'html'
11
+ @template = File.dirname(__FILE__) + '/hanna'
12
+ end
13
+ options << '--inline-source' unless options.include? '--inline-source' or options.include? '-S'
14
+ options << '--charset=UTF-8' if options.grep(/^(--charset$|-c\b)/).empty?
15
+
16
+ desc "Build the HTML documentation"
17
+ task name
18
+
19
+ desc "Force a rebuild of the RDOC files"
20
+ task paste("re", name) => [paste("clobber_", name), name]
21
+
22
+ desc "Remove rdoc products"
23
+ task paste("clobber_", name) do
24
+ rm_r rdoc_dir rescue nil
25
+ end
26
+
27
+ task :clobber => [paste("clobber_", name)]
28
+
29
+ directory @rdoc_dir
30
+ task name => [rdoc_target]
31
+ file rdoc_target => @rdoc_files + [$rakefile] do
32
+ rm_r @rdoc_dir rescue nil
33
+
34
+ begin
35
+ gem 'rdoc', '~> 2.0.0'
36
+ rescue Gem::LoadError
37
+ $stderr.puts "Couldn't load RDoc 2.0 gem"
38
+ end
39
+ require 'rdoc/rdoc'
40
+ require 'hanna/rdoc_patch'
41
+
42
+ RDoc::RDoc.new.document(option_list + @rdoc_files)
43
+ end
44
+ self
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ %h1= values["list_title"]
2
+ %ol#index-entries.classes
3
+ = render_class_tree make_class_tree(values["entries"])
@@ -0,0 +1,4 @@
1
+ %h1= values["list_title"]
2
+ %ol#index-entries{ :class => values["list_title"].downcase }
3
+ - for entry in values["entries"]
4
+ %li= link_to entry['name'], entry['href']
@@ -0,0 +1,11 @@
1
+ !!! Frameset
2
+ %html{ "xml:lang" => "en", :lang => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
3
+ %head
4
+ %title= values["title"]
5
+ %meta{ :content => "text/html; charset=#{values['charset']}", "http-equiv" => "Content-Type" }
6
+ %frameset{ :cols => "20%, *", :frameborder => 'no' }
7
+ %frameset{ :rows => "15%, 35%, 50%" }
8
+ %frame{ :name => "Files", :title => "Files", :src => "fr_file_index.html" }
9
+ %frame{ :name => "Classes", :src => "fr_class_index.html" }
10
+ %frame{ :name => "Methods", :src => "fr_method_index.html" }
11
+ %frame{ :name => "docwin", :src => values['initial_page'] }
@@ -0,0 +1,37 @@
1
+ !!! strict
2
+ - index = values['list_title']
3
+ %html{ :xmlns => "http://www.w3.org/1999/xhtml", 'xml:lang' => "en", :lang => "en" }
4
+ %head
5
+ %title= index || values['title']
6
+ %meta{ 'http-equiv' => "Content-Type", :content => "text/html; charset=#{values['charset']}" }
7
+ %link{ :rel => "stylesheet", :href => values["style_url"], :type => "text/css", :media => "screen" }
8
+ - unless index
9
+ %script{ :type => "text/javascript" }
10
+ :plain
11
+ function popupCode(url) {
12
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
13
+ }
14
+
15
+ function toggleCode(id) {
16
+ var code = document.getElementById(id)
17
+
18
+ code.style.display = code.style.display != 'block' ? 'block' : 'none'
19
+ return true
20
+ }
21
+
22
+ // Make codeblocks hidden by default
23
+ document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
24
+ - else
25
+ %base{ :target => 'docwin' }/
26
+
27
+ %body{ :class => index ? 'list' : 'page' }
28
+ - if index
29
+ #index= yield
30
+ - else
31
+ #wrapper{ :class => values["classmod"] ? 'class' : 'file' }
32
+ = yield
33
+ #footer-push
34
+ #footer
35
+ = link_to '<strong>Hanna</strong> RDoc template', 'http://github.com/mislav/hanna'
36
+ hand-crafted by
37
+ %strong= link_to 'Mislav', 'http://mislav.caboo.se/'
@@ -0,0 +1,34 @@
1
+ - methods = methods_from_sections values["sections"]
2
+ - unless methods.empty?
3
+ #method-list
4
+ %h2 Methods
5
+ - for type in ['public class', 'protected class', 'public instance', 'protected instance']
6
+ - unless (list = methods[type]).empty?
7
+ %h3= type
8
+ %ol
9
+ - for method in list
10
+ %li= link_to method["name"], '#' + method["aref"]
11
+
12
+ - if values["requires"] or values["toc"] or values["includes"]
13
+ #context
14
+ - if values["requires"]
15
+ #requires
16
+ %h2 Required files
17
+ %ol
18
+ - for req in values["requires"]
19
+ %li= link_to req["name"], req["aref"]
20
+
21
+ - if values["toc"]
22
+ #contents
23
+ %h2 Contents
24
+ %ol
25
+ - for item in values["toc"]
26
+ %li= link_to values["secname"], values["href"]
27
+
28
+ - if values["includes"]
29
+ #includes
30
+ %h2 Included modules
31
+ %ol
32
+ - for inc in values["includes"]
33
+ %li= link_to inc["name"], inc["aref"]
34
+
@@ -0,0 +1,46 @@
1
+ - file_page = !values["classmod"]
2
+ - title_in_description = values["description"] && values["description"] =~ /^\s*<h1>/m
3
+
4
+ .header
5
+ - title = capture_haml do
6
+ - if file_page
7
+ = values["short_name"]
8
+ - else
9
+ %span.type= values["classmod"]
10
+ = values["full_name"]
11
+ - if title_in_description
12
+ .name= title
13
+ - else
14
+ %h1.name= title
15
+
16
+ - if file_page
17
+ .paths
18
+ = values["full_path"]
19
+ - if values["cvsurl"]
20
+ == (#{link_to 'view online', values["cvsurl"]})
21
+ - else
22
+ %ol.paths
23
+ - for file in values["infiles"]
24
+ %li
25
+ = link_to file["full_path"], file["full_path_url"]
26
+ - if file["cvsurl"]
27
+ == (#{link_to 'view online', file["cvsurl"]})
28
+
29
+ - if values["parent"] then
30
+ .parent
31
+ Parent:
32
+ %strong= link_to values["parent"], values["par_url"]
33
+
34
+ - if values["dtm_modified"]
35
+ .last-update
36
+ Last Update:
37
+ %span.datetime= values["dtm_modified"]
38
+
39
+ #content
40
+ - if values["diagram"]
41
+ #diagram= values["diagram"]
42
+
43
+ - if values["description"]
44
+ #description~ values["description"]
45
+
46
+ = yield
@@ -0,0 +1,97 @@
1
+ - for section in values["sections"]
2
+ #section
3
+ - if section["sectitle"]
4
+ %h2= link_to section["sectitle"], section["secsequence"]
5
+ - if section["seccomment"]
6
+ .section-comment= section["seccomment"]
7
+ - if values["classlist"]
8
+ #class-list
9
+ %h3 Classes and Modules
10
+ = values["classlist"]
11
+
12
+ - if values["constants"]
13
+ #constants-list
14
+ %h3.section-bar Constants
15
+ .name-list
16
+ %table{ :summary => "Constants" }
17
+ - for const in values["constants"]
18
+ %tr.top-aligned-row.context-row
19
+ %td.context-item-name
20
+ = const["name"]
21
+ %td
22
+ \=
23
+ %td.context-item-value
24
+ = const["value"]
25
+ - if values["desc"] then
26
+ %td{ :width => "3em" }
27
+ &nbsp;
28
+ %td.context-item-desc
29
+ = const["desc"]
30
+
31
+ - if values["aliases"]
32
+ #aliases-list
33
+ %h3.section-bar External Aliases
34
+ .name-list
35
+ %table{ :summary => "aliases" }
36
+ - for alia in values["aliases"]
37
+ %tr.top-aligned-row.context-row
38
+ %td.context-item-name
39
+ = values["old_name"]
40
+ %td
41
+ \-&gt;
42
+ %td.context-item-value
43
+ = values["new_name"]
44
+ - if values["desc"] then
45
+ %tr.top-aligned-row.context-row
46
+ %td
47
+ &nbsp;
48
+ %td.context-item-desc{ :colspan => "2" }
49
+ = values["desc"]
50
+
51
+ - if values["attributes"]
52
+ #attribute-list
53
+ %h3.section-bar Attributes
54
+ .name-list
55
+ %table
56
+ - for attr in values["attributes"]
57
+ %tr.top-aligned-row.context-row
58
+ %td.context-item-name
59
+ = values["name"]
60
+ - if values["rw"] then
61
+ %td.context-item-value
62
+ = "[#{values['rw']}]"
63
+ - else
64
+ %td.context-item-value &nbsp;
65
+ %td.context-item-desc
66
+ = values["a_desc"]
67
+
68
+ - if section["method_list"]
69
+ #methods
70
+ - for list in section["method_list"]
71
+ - if list["methods"] then
72
+ %h3== #{list["type"]} #{list["category"].downcase} methods
73
+
74
+ - for method in list["methods"]
75
+ .method{ :id => "method-#{method['aref']}", :class => "#{list['type']}-#{list['category']}".downcase }
76
+ %a{ :name => method["aref"] }
77
+ .synopsis
78
+ - method_html = capture_haml do
79
+ - if method["callseq"]
80
+ %span.name= method["callseq"]
81
+ - else
82
+ %span.name= method["name"]
83
+ %span.arguments= method["params"]
84
+ - if method["codeurl"]
85
+ %a.method-signature{ :href => method["codeurl"], :onclick => "popupCode(this.href); return false", :target => "Code" }
86
+ = method_html
87
+ - else
88
+ = method_html
89
+ - if method["m_desc"]
90
+ .description
91
+ ~ method["m_desc"]
92
+ - if method["sourcecode"]
93
+ .source
94
+ - name = "#{method['aref']}-source"
95
+ %a.source-toggle{ :href => "#", :onclick => "toggleCode('#{name}'); return false" }
96
+ [show source]
97
+ ~ "<pre id='#{name}'>#{method["sourcecode"]}</pre>"
@@ -0,0 +1,290 @@
1
+ !title_font = Times, "Times New Roman", Georgia, serif
2
+ !code_font = Inconsolata, Monaco, "DejaVu Sans", Courier, "Courier New", monospace
3
+
4
+ !light_link = #369
5
+ !link = !light_link - 40
6
+ !light_text = #666
7
+
8
+ html, body
9
+ :height 100%
10
+ body
11
+ :font-family Verdana, Arial, Helvetica, sans-serif
12
+ :font-size 90%
13
+ :margin 0
14
+ :padding 0
15
+ :background white
16
+
17
+ #wrapper
18
+ :min-height 100%
19
+ :height auto !important
20
+ :height 100%
21
+ :margin 0 auto -43px
22
+ :border-left 1px solid gray
23
+ #footer-push
24
+ :height 43px
25
+ div.header, #footer
26
+ :font-size 80%
27
+ :background #eee
28
+ #footer
29
+ :border-top 1px solid silver
30
+ :margin-top 12px
31
+ :padding 0 2em
32
+ :line-height 30px
33
+ :text-align center
34
+ :font-variant small-caps
35
+
36
+ // self-clearing
37
+ .clearing
38
+ &:after
39
+ :content "."
40
+ :visibility hidden
41
+ :height 0
42
+ :display block
43
+ :clear both
44
+ * html &
45
+ :height 1px
46
+ *:first-child + html
47
+ :overflow hidden
48
+
49
+ h1, h2, h3, h4, h5, h6
50
+ :margin 0
51
+ :font-weight normal
52
+
53
+ a
54
+ :color = !link
55
+ &:hover
56
+ :background = !light_link
57
+ :text-decoration none
58
+ :color #eef
59
+ #description, .method .description, .header
60
+ a
61
+ :color = !light_link
62
+ &:hover
63
+ :color #eee
64
+ h1, h2, h3
65
+ a
66
+ :color = !link
67
+
68
+ ol
69
+ :margin 0
70
+ :padding 0
71
+ :list-style none
72
+ li
73
+ :margin-left 0
74
+ white-space: nowrap
75
+ table
76
+ :margin-bottom 1em
77
+ :font-size 1em
78
+ :border-collapse collapse
79
+ td, th
80
+ :padding .4em .8em
81
+ thead
82
+ :background-color #e8e8e8
83
+ th
84
+ :font-variant small-caps
85
+ :color = !light_text
86
+ tr
87
+ :border-bottom 1px solid silver
88
+
89
+ #index
90
+ :font 85%/1.2 Arial, Helvetica, sans-serif
91
+ a
92
+ :text-decoration none
93
+ h1
94
+ :padding .2em .5em .1em
95
+ :background #ccc
96
+ :font = "small-caps 1.1em" !title_font
97
+ :color #333
98
+ :border-bottom 1px solid gray
99
+ :border-top 1px solid #aaa
100
+ ol
101
+ :padding .4em .5em
102
+ li
103
+ :white-space nowrap
104
+ #index-entries.classes
105
+ :font-size 1.1em
106
+ ol
107
+ :padding 0
108
+ span.class
109
+ :display none
110
+ .class, a
111
+ :font-weight bold
112
+ .parent
113
+ :font-weight normal
114
+
115
+ div.header
116
+ :padding .5em 12px
117
+ :font-family Arial, Helvetica, sans-serif
118
+ :border-bottom 1px solid silver
119
+ .name
120
+ :font-size 1.6em
121
+ :font-family = !title_font
122
+ .type
123
+ :color = !light_text
124
+ :font-size 80%
125
+ :font-variant small-caps
126
+ h1.name
127
+ :font-size 2.2em
128
+ .paths, .last-update, .parent
129
+ :color = !light_text
130
+ ol.paths
131
+ :padding-left .5em
132
+ .last-update .datetime
133
+ :color = !light_text - 30
134
+ .parent
135
+ :margin-top .3em
136
+ strong
137
+ :font-weight normal
138
+ :color = !light_text - 30
139
+
140
+ #content
141
+ :padding 12px
142
+ div.class &
143
+ :position relative
144
+ :width 73%
145
+
146
+ pre, .method .synopsis
147
+ :font = 15px !code_font
148
+ pre
149
+ :color black
150
+ :background #eee
151
+ :border 1px solid silver
152
+ :padding 0 .5em .8em .5em
153
+ :overflow auto
154
+ p, li
155
+ code, tt
156
+ :font = 15px !code_font
157
+ :background #ffffe3
158
+ :padding 2px 3px
159
+
160
+ #description
161
+ // :max-width 60em
162
+ p
163
+ :margin-top .5em
164
+ h1, h2, h3
165
+ :font-family = !title_font
166
+ h1
167
+ :font-size 2.2em
168
+ :margin-bottom .2em
169
+ :border-bottom 3px double #d8d8d8
170
+ :padding-bottom .1em
171
+ h2
172
+ :font-size 1.8em
173
+ :color #0E3062
174
+ :margin .8em 0 .3em 0
175
+ h3
176
+ :font-size 1.6em
177
+ :margin .8em 0 .3em 0
178
+ :color = !light_text
179
+
180
+ #method-list
181
+ :position absolute
182
+ :top 12px
183
+ :right -31%
184
+ :width 27%
185
+ :background #eee
186
+ :border 1px solid silver
187
+ :padding .5em 1em
188
+ :overflow hidden
189
+ h2
190
+ :font-size 1.3em
191
+ h3
192
+ :font-variant small-caps
193
+ :text-transform capitalize
194
+ :font-family = !title_font
195
+ :color #666
196
+ :font-size 1.1em
197
+ ol
198
+ :padding 0 0 .5em .5em
199
+
200
+ #context
201
+ :font-size 85%
202
+ :padding-left 1.5em
203
+ :border-top 1px dashed silver
204
+ :margin-top 1em
205
+ h2
206
+ :color #333
207
+ :font = "bold small-caps 1.3em" !title_font
208
+ :margin .5em 0 .1em 0
209
+
210
+ #methods
211
+ h3
212
+ :font = "small-caps 1.2em" !title_font
213
+ :color #444
214
+ :margin 1em 0 .2em 0
215
+
216
+ .method
217
+ :border 1px solid silver
218
+ :margin-top .5em
219
+ :background #eee
220
+ .synopsis
221
+ :color black
222
+ :background silver
223
+ :padding .2em 1em
224
+ :font-size 16px
225
+ .name
226
+ :font-weight bold
227
+ a
228
+ :text-decoration none
229
+ .description
230
+ :padding 0 1em
231
+ pre
232
+ :background #f8f8f8
233
+ .source
234
+ :margin .5em 0
235
+ .source-toggle
236
+ :font-size 85%
237
+ :margin-left 1em
238
+ .public-class
239
+ :background #ffd
240
+
241
+ #content .method .source pre
242
+ :background #262626
243
+ :color #ffdead
244
+ :margin 1em
245
+ :padding 0.5em
246
+ :border 1px dashed #999
247
+ :overflow hidden
248
+
249
+ .standalone-code
250
+ :background #221111
251
+ :color #ffdead
252
+ :overflow hidden
253
+
254
+ .ruby-constant
255
+ :color #7fffd4
256
+ :background transparent
257
+
258
+ .ruby-keyword
259
+ :color #00ffff
260
+ :background transparent
261
+
262
+ .ruby-ivar
263
+ :color #eedd82
264
+ :background transparent
265
+
266
+ .ruby-operator
267
+ :color #00ffee
268
+ :background transparent
269
+
270
+ .ruby-identifier
271
+ :color #ffdead
272
+ :background transparent
273
+
274
+ .ruby-node
275
+ :color #ffa07a
276
+ :background transparent
277
+
278
+ .ruby-comment
279
+ :color #b22222
280
+ :font-weight bold
281
+ :background transparent
282
+
283
+ .ruby-regexp
284
+ :color #ffa07a
285
+ :background transparent
286
+
287
+ .ruby-value
288
+ :color #7fffd4
289
+ :background transparent
290
+
@@ -0,0 +1,84 @@
1
+ require 'yaml'
2
+ require 'cgi'
3
+
4
+ RDoc::TemplatePage.class_eval do
5
+ def write_html_on(io, values)
6
+ result = @templates.reverse.inject(nil) do |previous, template|
7
+ case template
8
+ when Haml::Engine
9
+ template.to_html(get_binding, :values => values) { previous }
10
+ when Sass::Engine
11
+ template.to_css
12
+ when String
13
+ ERB.new(template).result(get_binding(values){ previous })
14
+ when nil
15
+ previous
16
+ else
17
+ raise "don't know how to handle a template of class '#{template.class.name}'"
18
+ end
19
+ end
20
+
21
+ io.write result
22
+ rescue
23
+ $stderr.puts "error while writing to #{io.inspect}"
24
+ raise
25
+ end
26
+
27
+ protected
28
+
29
+ ### View helpers ###
30
+
31
+ def link_to(text, url = nil)
32
+ href(url, text)
33
+ end
34
+
35
+ def debug(text)
36
+ "<pre>#{h YAML::dump(text)}</pre>"
37
+ end
38
+
39
+ def h(html)
40
+ CGI::escapeHTML html
41
+ end
42
+
43
+ def methods_from_sections(sections)
44
+ sections.inject(Hash.new {|h, k| h[k] = []}) do |methods, section|
45
+ section['method_list'].each do |ml|
46
+ methods["#{ml['type']} #{ml['category']}".downcase].concat ml['methods']
47
+ end if section['method_list']
48
+ methods
49
+ end
50
+ end
51
+
52
+ def make_class_tree(entries)
53
+ entries.inject({}) do |tree, entry|
54
+ leaf = entry['name'].split('::').inject(tree) do |branch, klass|
55
+ branch[klass] ||= {}
56
+ end
57
+ leaf['_href'] = entry['href']
58
+ tree
59
+ end
60
+ end
61
+
62
+ def render_class_tree(tree, parent = nil)
63
+ parent = parent + '::' if parent
64
+ tree.keys.sort.inject('') do |out, name|
65
+ unless name == '_href'
66
+ subtree = tree[name]
67
+ text = parent ? "<span class='parent'>#{parent}</span>#{name}" : name
68
+ out << '<li>'
69
+ out << (subtree['_href'] ? link_to(text, subtree['_href']) : "<span class='class'>#{text}</span>")
70
+ if subtree.keys.size > 1
71
+ out << "\n<ol>" << render_class_tree(subtree, parent.to_s + name) << "\n</ol>"
72
+ end
73
+ out << '</li>'
74
+ end
75
+ out
76
+ end
77
+ end
78
+
79
+ private
80
+
81
+ def get_binding(values = nil)
82
+ binding
83
+ end
84
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mislav-hanna
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - "Mislav Marohni\xC4\x87"
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-02 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rdoc
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 2.0.0
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: haml
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.8.2
32
+ version:
33
+ description: Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind.
34
+ email: mislav.marohnic@gmail.com
35
+ executables:
36
+ - hanna
37
+ extensions: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ files:
42
+ - README.markdown
43
+ - Rakefile
44
+ - bin
45
+ - bin/hanna
46
+ - lib
47
+ - lib/hanna
48
+ - lib/hanna/hanna.rb
49
+ - lib/hanna/rdoc_patch.rb
50
+ - lib/hanna/rdoctask.rb
51
+ - lib/hanna/template_files
52
+ - lib/hanna/template_files/class_index.haml
53
+ - lib/hanna/template_files/file_index.haml
54
+ - lib/hanna/template_files/index.haml
55
+ - lib/hanna/template_files/layout.haml
56
+ - lib/hanna/template_files/method_list.haml
57
+ - lib/hanna/template_files/page.haml
58
+ - lib/hanna/template_files/sections.haml
59
+ - lib/hanna/template_files/styles.sass
60
+ - lib/hanna/template_page_patch.rb
61
+ has_rdoc: false
62
+ homepage: http://github.com/mislav/hanna
63
+ post_install_message:
64
+ rdoc_options: []
65
+
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project:
83
+ rubygems_version: 1.0.1
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: An RDoc template that rocks
87
+ test_files: []
88
+