public
Rubygem
Description: More than just a new RDoc template
Clone URL: git://github.com/mislav/hanna.git
Search Repo:
don't use Times and Inconsolata, switch to Georgia; many other style 
tweaks.
extracted view helpers to Hanna::ViewHelpers
mislav (author)
Tue May 06 18:30:33 -0700 2008
commit  c65a1c6db31a2ea70801478a40061592286cce95
tree    97df6a888663ecdcebb8693e4a4f641a4853a290
parent  8c7cf5e964144ee3943c62690b46501f19d9ef05
...
1
2
 
 
 
 
3
4
 
 
 
 
 
 
 
...
1
 
2
3
4
5
6
 
7
8
9
10
11
12
13
0
@@ -1,5 +1,14 @@
0
 %h1= values["list_title"]
0
-%ol#index-entries{ :class => values["list_title"].downcase }
0
+- type = values["list_title"].downcase
0
+- any_hidden = false
0
+
0
+%ol#index-entries{ :class => type }
0
   - for entry in values["entries"]
0
- %li= link_to entry['name'], entry['href']
0
+ - hide = type == 'files' && entry['name'] =~ /\.rb$/
0
+ - any_hidden = true if hide
0
+ %li{ :class => hide ? 'other' : nil }= link_to entry['name'], entry['href']
0
+
0
+ - if any_hidden
0
+ %li
0
+ %a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
...
3
4
5
6
 
7
8
9
...
3
4
5
 
6
7
8
9
0
@@ -3,7 +3,7 @@
0
   %head
0
     %title= values["title"]
0
     %meta{ :content => "text/html; charset=#{values['charset']}", "http-equiv" => "Content-Type" }
0
- %frameset{ :cols => "20%, *", :frameborder => 'no' }
0
+ %frameset{ :cols => "20%, *" }
0
     %frameset{ :rows => "15%, 35%, 50%" }
0
       %frame{ :name => "Files", :title => "Files", :src => "fr_file_index.html" }
0
       %frame{ :name => "Classes", :src => "fr_class_index.html" }
...
20
21
22
23
24
 
 
25
26
27
 
 
 
28
29
30
...
20
21
22
 
 
23
24
25
26
27
28
29
30
31
32
33
0
@@ -20,11 +20,14 @@
0
         == (#{link_to 'view online', values["cvsurl"]})
0
   - else
0
     %ol.paths
0
- - for file in values["infiles"]
0
- %li
0
+ - values["infiles"].each_with_index do |file, index|
0
+ %li{ :class => index > 0 ? 'other' : nil }
0
           = link_to file["full_path"], file["full_path_url"]
0
           - if file["cvsurl"]
0
             == (#{link_to 'view online', file["cvsurl"]})
0
+ - if values["infiles"].size > 1
0
+ %li
0
+ %a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
0
           
0
   - if values["parent"] then
0
     .parent
...
1
2
 
 
 
 
3
4
5
6
...
19
20
21
22
23
24
25
26
27
28
29
...
32
33
34
 
35
36
37
...
71
72
73
74
 
 
 
 
 
 
75
76
77
...
86
87
88
 
 
 
 
 
 
 
 
 
 
 
89
90
91
92
...
93
94
95
96
 
97
98
99
100
101
102
103
104
...
105
106
107
108
 
109
110
 
111
112
113
114
115
116
 
 
117
118
119
...
127
128
129
130
131
132
133
134
135
136
137
138
139
...
138
139
140
141
 
142
143
144
 
145
146
147
 
148
149
150
151
152
153
154
 
155
156
 
157
158
 
 
 
159
160
161
162
163
...
177
178
179
 
 
 
 
 
180
181
182
183
 
184
185
186
187
 
188
189
190
...
221
222
223
224
225
226
227
...
236
237
238
239
 
 
 
 
240
241
242
...
 
 
1
2
3
4
5
6
7
8
...
21
22
23
 
24
25
26
 
27
28
29
...
32
33
34
35
36
37
38
...
72
73
74
 
75
76
77
78
79
80
81
82
83
...
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
110
111
112
 
113
114
115
 
116
117
118
119
120
...
121
122
123
 
124
125
 
126
127
128
129
130
131
 
132
133
134
135
136
...
144
145
146
 
 
147
148
149
150
151
152
153
154
...
153
154
155
 
156
157
158
 
159
160
161
 
162
163
164
165
166
167
168
 
169
170
 
171
172
173
174
175
176
177
178
179
180
181
...
195
196
197
198
199
200
201
202
203
204
205
 
206
207
208
209
 
210
211
212
213
...
244
245
246
 
247
248
249
...
258
259
260
 
261
262
263
264
265
266
267
0
@@ -1,5 +1,7 @@
0
-!title_font = Times, "Times New Roman", Georgia, serif
0
-!code_font = Inconsolata, Monaco, "DejaVu Sans", Courier, "Courier New", monospace
0
+!title_font = Georgia, serif
0
+!code_font_family = Monaco, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace
0
+!code_font_size = 14px
0
+!code_font = !code_font_size !code_font_family
0
 
0
 !light_link = #369
0
 !link = !light_link - 40
0
0
@@ -19,11 +21,9 @@
0
   :height auto !important
0
   :height 100%
0
   :margin 0 auto -43px
0
- :border-left 1px solid gray
0
 #footer-push
0
   :height 43px
0
 div.header, #footer
0
- :font-size 80%
0
   :background #eee
0
 #footer
0
   :border-top 1px solid silver
0
@@ -32,6 +32,7 @@
0
   :line-height 30px
0
   :text-align center
0
   :font-variant small-caps
0
+ :font-size 95%
0
 
0
 // self-clearing
0
 .clearing
0
@@ -71,7 +72,12 @@
0
   :list-style none
0
   li
0
     :margin-left 0
0
- white-space: nowrap
0
+ :white-space nowrap
0
+ &.other
0
+ :display none
0
+ol.expanded li.other
0
+ :display list-item
0
+
0
 table
0
   :margin-bottom 1em
0
   :font-size 1em
0
@@ -86,6 +92,17 @@
0
   tr
0
     :border-bottom 1px solid silver
0
 
0
+#index, div.header
0
+ a.show
0
+ :text-decoration underline
0
+ :font-style italic
0
+ :color = !light_text
0
+ &:after
0
+ :content " ..."
0
+ &:hover
0
+ :color black
0
+ :background #ffe
0
+
0
 #index
0
   :font 85%/1.2 Arial, Helvetica, sans-serif
0
   a
0
0
@@ -93,10 +110,9 @@
0
   h1
0
     :padding .2em .5em .1em
0
     :background #ccc
0
- :font = "small-caps 1.1em" !title_font
0
+ :font = "small-caps 1.2em" !title_font
0
     :color #333
0
     :border-bottom 1px solid gray
0
- :border-top 1px solid #aaa
0
   ol
0
     :padding .4em .5em
0
     li
0
0
0
@@ -105,15 +121,16 @@
0
     :font-size 1.1em
0
     ol
0
       :padding 0
0
- span.class
0
+ span.nodoc
0
       :display none
0
- .class, a
0
+ span.nodoc, a
0
       :font-weight bold
0
     .parent
0
       :font-weight normal
0
   
0
 div.header
0
- :padding .5em 12px
0
+ :font-size 80%
0
+ :padding .5em 2%
0
   :font-family Arial, Helvetica, sans-serif
0
   :border-bottom 1px solid silver
0
   .name
0
@@ -127,8 +144,6 @@
0
     :font-size 2.2em
0
   .paths, .last-update, .parent
0
     :color = !light_text
0
- ol.paths
0
- :padding-left .5em
0
   .last-update .datetime
0
     :color = !light_text - 30
0
   .parent
0
0
0
0
0
0
@@ -138,24 +153,27 @@
0
       :color = !light_text - 30
0
 
0
 #content
0
- :padding 12px
0
+ :padding 12px 2%
0
   div.class &
0
     :position relative
0
- :width 73%
0
+ :width 72%
0
   
0
   pre, .method .synopsis
0
- :font = 15px !code_font
0
+ :font = !code_font
0
   pre
0
     :color black
0
     :background #eee
0
     :border 1px solid silver
0
     :padding 0 .5em .8em .5em
0
     :overflow auto
0
- p, li
0
+ p, li, dd
0
     code, tt
0
- :font = 15px !code_font
0
+ :font = !code_font
0
       :background #ffffe3
0
       :padding 2px 3px
0
+ h1, h2, h3, h4, h5, h6
0
+ code, tt
0
+ :font-size 1.1em
0
   
0
   #description
0
     // :max-width 60em
0
0
0
@@ -177,14 +195,19 @@
0
       :margin .8em 0 .3em 0
0
       :color = !light_text
0
 
0
+ #description, .method .description
0
+ ul
0
+ :margin .8em 0
0
+ :padding-left 1.5em
0
+
0
 #method-list
0
   :position absolute
0
   :top 12px
0
- :right -31%
0
+ :right -29%
0
   :width 27%
0
   :background #eee
0
   :border 1px solid silver
0
- :padding .5em 1em
0
+ :padding .4em 1%
0
   :overflow hidden
0
   h2
0
     :font-size 1.3em
0
@@ -221,7 +244,6 @@
0
       :color black
0
       :background silver
0
       :padding .2em 1em
0
- :font-size 16px
0
       .name
0
         :font-weight bold
0
       a
0
@@ -236,7 +258,10 @@
0
       :font-size 85%
0
       :margin-left 1em
0
   .public-class
0
- :background #ffd
0
+ :background #ffffe4
0
+ .public-instance .synopsis
0
+ :color #eee
0
+ :background = !light_link
0
 
0
 #content .method .source pre
0
   :background #262626
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
0
@@ -1 +1,67 @@
0
+require 'yaml'
0
+require 'cgi'
0
+
0
+module Hanna
0
+ module TemplateHelpers
0
+ protected
0
+
0
+ def link_to(text, url = nil, classname = nil)
0
+ class_attr = classname ? %[ class="#{classname}"] : ''
0
+
0
+ if url
0
+ %[<a href="#{url}"#{class_attr}>#{text}</a>]
0
+ elsif classname
0
+ %[<span#{class_attr}>#{text}</span>]
0
+ else
0
+ text
0
+ end
0
+ end
0
+
0
+ def debug(text)
0
+ "<pre>#{h YAML::dump(text)}</pre>"
0
+ end
0
+
0
+ def h(html)
0
+ CGI::escapeHTML html
0
+ end
0
+
0
+ def methods_from_sections(sections)
0
+ sections.inject(Hash.new {|h, k| h[k] = []}) do |methods, section|
0
+ section['method_list'].each do |ml|
0
+ methods["#{ml['type']} #{ml['category']}".downcase].concat ml['methods']
0
+ end if section['method_list']
0
+ methods
0
+ end
0
+ end
0
+
0
+ def make_class_tree(entries)
0
+ entries.inject({}) do |tree, entry|
0
+ if entry['href']
0
+ leaf = entry['name'].split('::').inject(tree) do |branch, klass|
0
+ branch[klass] ||= {}
0
+ end
0
+ leaf['_href'] = entry['href']
0
+ end
0
+ tree
0
+ end
0
+ end
0
+
0
+ def render_class_tree(tree, parent = nil)
0
+ parent = parent + '::' if parent
0
+ tree.keys.sort.inject('') do |out, name|
0
+ unless name == '_href'
0
+ subtree = tree[name]
0
+ text = parent ? %[<span class="parent">#{parent}</span>#{name}] : name
0
+ out << '<li>'
0
+ out << (subtree['_href'] ? link_to(text, subtree['_href']) : %[<span class="nodoc">#{text}</span>])
0
+ if subtree.keys.size > 1
0
+ out << "\n<ol>" << render_class_tree(subtree, parent.to_s + name) << "\n</ol>"
0
+ end
0
+ out << '</li>'
0
+ end
0
+ out
0
+ end
0
+ end
0
+ end
0
+end
...
1
2
 
3
4
 
 
 
 
5
6
7
...
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
...
 
 
1
2
3
4
5
6
7
8
9
10
...
25
26
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
29
30
0
@@ -1,7 +1,10 @@
0
-require 'yaml'
0
-require 'cgi'
0
+require 'hanna/template_helpers'
0
 
0
 RDoc::TemplatePage.class_eval do
0
+
0
+ include Hanna::TemplateHelpers
0
+
0
+ # overwrite the original method
0
   def write_html_on(io, values)
0
     result = @templates.reverse.inject(nil) do |previous, template|
0
       case template
0
@@ -22,58 +25,6 @@
0
   rescue
0
     $stderr.puts "error while writing to #{io.inspect}"
0
     raise
0
- end
0
-
0
- protected
0
-
0
- ### View helpers ###
0
-
0
- def link_to(text, url = nil)
0
- href(url, text)
0
- end
0
-
0
- def debug(text)
0
- "<pre>#{h YAML::dump(text)}</pre>"
0
- end
0
-
0
- def h(html)
0
- CGI::escapeHTML html
0
- end
0
-
0
- def methods_from_sections(sections)
0
- sections.inject(Hash.new {|h, k| h[k] = []}) do |methods, section|
0
- section['method_list'].each do |ml|
0
- methods["#{ml['type']} #{ml['category']}".downcase].concat ml['methods']
0
- end if section['method_list']
0
- methods
0
- end
0
- end
0
-
0
- def make_class_tree(entries)
0
- entries.inject({}) do |tree, entry|
0
- leaf = entry['name'].split('::').inject(tree) do |branch, klass|
0
- branch[klass] ||= {}
0
- end
0
- leaf['_href'] = entry['href']
0
- tree
0
- end
0
- end
0
-
0
- def render_class_tree(tree, parent = nil)
0
- parent = parent + '::' if parent
0
- tree.keys.sort.inject('') do |out, name|
0
- unless name == '_href'
0
- subtree = tree[name]
0
- text = parent ? "<span class='parent'>#{parent}</span>#{name}" : name
0
- out << '<li>'
0
- out << (subtree['_href'] ? link_to(text, subtree['_href']) : "<span class='class'>#{text}</span>")
0
- if subtree.keys.size > 1
0
- out << "\n<ol>" << render_class_tree(subtree, parent.to_s + name) << "\n</ol>"
0
- end
0
- out << '</li>'
0
- end
0
- out
0
- end
0
   end
0
 
0
   private

Comments

    No one has commented yet.