rogerdpack-hanna 0.1.7

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.
@@ -0,0 +1,83 @@
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
+
8
+ - if section[:classlist]
9
+ #class-list
10
+ %h2 Classes and Modules
11
+ = section[:classlist]
12
+
13
+ - if section[:constants]
14
+ #constants-list
15
+ %h2 Constants
16
+ .name-list
17
+ %table{ :summary => "Constants" }
18
+ - for const in section[:constants]
19
+ %tr.top-aligned-row.context-row
20
+ %td.context-item-name= const[:name]
21
+ %td =
22
+ %td.context-item-value= const[:value]
23
+ - if const[:desc] then
24
+ %td  
25
+ %td.context-item-desc= const[:desc]
26
+
27
+ - if section[:aliases]
28
+ #aliases-list
29
+ %h2 External Aliases
30
+ .name-list
31
+ %table{ :summary => "External aliases" }
32
+ - for alia in section[:aliases]
33
+ %tr.top-aligned-row.context-row
34
+ %td.context-item-name= alia[:old_name]
35
+ %td ->
36
+ %td.context-item-value= alia[:new_name]
37
+ - if alia[:desc] then
38
+ %tr.top-aligned-row.context-row
39
+ %td  
40
+ %td.context-item-desc{ :colspan => "2" }
41
+ = alia[:desc]
42
+
43
+ - if section[:attributes]
44
+ #attribute-list
45
+ %h2.section-bar Attributes
46
+ .name-list
47
+ %table
48
+ - for attr in section[:attributes]
49
+ %tr.top-aligned-row.context-row
50
+ %td.context-item-name= attr[:name]
51
+ %td.context-item-value= attr[:rw] ? "[#{attr[:rw]}]" : ' '
52
+ %td.context-item-desc= attr[:a_desc]
53
+
54
+ - if section[:method_list]
55
+ #methods
56
+ - for list in section[:method_list]
57
+ - if list[:methods] then
58
+ %h2== #{list[:type]} #{list[:category].downcase} methods
59
+
60
+ - for method in list[:methods]
61
+ .method{ :id => "method-#{method[:aref]}", :class => "#{list[:type]}-#{list[:category]}".downcase }
62
+ %a{ :name => method[:aref] }
63
+ .synopsis
64
+ - method_html = capture_haml do
65
+ - if method[:callseq]
66
+ %span.name= method[:callseq]
67
+ - else
68
+ %span.name= method[:name]
69
+ %span.arguments= method[:params]
70
+ - if method[:codeurl]
71
+ %a.method-signature{ :href => method[:codeurl], :onclick => "popupCode(this.href); return false", :target => "Code" }
72
+ = method_html
73
+ - else
74
+ = method_html
75
+ - if method[:m_desc]
76
+ .description
77
+ ~ sanitize_code_blocks method[:m_desc]
78
+ - if method[:sourcecode]
79
+ .source
80
+ - name = "#{method[:aref]}-source"
81
+ %a.source-toggle{ :href => "#", :onclick => "toggleCode('#{name}'); return false" }
82
+ [show source]
83
+ ~ "<pre id='#{name}'>#{method[:sourcecode]}</pre>"
@@ -0,0 +1,359 @@
1
+ !title_font = Georgia, serif
2
+ !body_font = "Lucida Grande", Verdana, Arial, Helvetica, "sans-serif"
3
+ !code_font_family = Monaco, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace
4
+ !code_font_size = 14px
5
+ !code_font = !code_font_size !code_font_family
6
+
7
+ !light_link = #369
8
+ !link = !light_link - 40
9
+ !light_text = #666
10
+ !dark_blue_text = #0E3062
11
+
12
+ html, body
13
+ :height 100%
14
+ body
15
+ :font-family = !body_font
16
+ :font-size 90%
17
+ :margin 0
18
+ :padding 0
19
+ :background white
20
+ :color black
21
+
22
+ #wrapper
23
+ :min-height 100%
24
+ :height auto !important
25
+ :height 100%
26
+ :margin 0 auto -43px
27
+ #footer-push
28
+ :height 43px
29
+ div.header, #footer
30
+ :background #eee
31
+ #footer
32
+ :border-top 1px solid silver
33
+ :margin-top 12px
34
+ :padding 0 2em
35
+ :line-height 30px
36
+ :text-align center
37
+ :font-variant small-caps
38
+ :font-size 95%
39
+
40
+ // self-clearing
41
+ .clearing
42
+ &:after
43
+ :content "."
44
+ :visibility hidden
45
+ :height 0
46
+ :display block
47
+ :clear both
48
+ * html &
49
+ :height 1px
50
+ *:first-child + html
51
+ :overflow hidden
52
+
53
+ h1, h2, h3, h4, h5, h6
54
+ :margin 0
55
+ :font-weight normal
56
+
57
+ a
58
+ :color = !link
59
+ &:hover
60
+ :background = !light_link
61
+ :text-decoration none
62
+ :color #eef
63
+
64
+ #diagram
65
+ img
66
+ :border = 0
67
+
68
+ #description, .method .description, .header
69
+ a
70
+ :color = !light_link
71
+ &:hover
72
+ :color #eee
73
+ h1, h2, h3, h4, h5, h6
74
+ a
75
+ :color = !link
76
+
77
+ ol
78
+ :margin 0
79
+ :padding 0
80
+ :list-style none
81
+ li
82
+ :margin-left 0
83
+ :white-space nowrap
84
+ &.other
85
+ :display none
86
+ ol.expanded li.other
87
+ :display list-item
88
+
89
+ table
90
+ :margin-bottom 1em
91
+ :font-size 1em
92
+ :border-collapse collapse
93
+ td, th
94
+ :padding .4em .8em
95
+ thead
96
+ :background-color #e8e8e8
97
+ th
98
+ :font-variant small-caps
99
+ :color = !light_text
100
+ tr
101
+ :border-bottom 1px solid silver
102
+
103
+ #index, div.header
104
+ a.show
105
+ :text-decoration underline
106
+ :font-style italic
107
+ :color = !light_text
108
+ &:after
109
+ :content " ..."
110
+ &:hover
111
+ :color black
112
+ :background #ffe
113
+
114
+ #index
115
+ :font 85%/1.2 Arial, Helvetica, sans-serif
116
+ a
117
+ :text-decoration none
118
+ h1
119
+ :padding .2em .5em .1em
120
+ :background #ccc
121
+ :font = "small-caps 1.2em" !title_font
122
+ :color #333
123
+ :border-bottom 1px solid gray
124
+ form
125
+ :margin 0
126
+ :padding 0
127
+ input
128
+ :margin .4em 3px 0 .4em
129
+ :width 80%
130
+ #search.untouched
131
+ :color #777777
132
+ .clear_button
133
+ :-moz-border-radius 7px
134
+ :-webkit-border-radius 7px
135
+ :background #AAA
136
+ :color white
137
+ :padding 0 5px 1px 5px
138
+ :cursor pointer
139
+ ol
140
+ :padding .4em .5em
141
+ li
142
+ :white-space nowrap
143
+ #index-entries li a
144
+ :padding 1px 2px
145
+ #index-entries.classes
146
+ :font-size 1.1em
147
+ ol
148
+ :padding 0
149
+ span.nodoc
150
+ :display none
151
+ span.nodoc, a
152
+ :font-weight bold
153
+ .parent
154
+ :font-weight normal
155
+ #index-entries.methods, #search-results.methods
156
+ li
157
+ :margin-bottom 0.2em
158
+ a
159
+ .method_name
160
+ :margin-right 0.25em
161
+ .module_name
162
+ :color #666666
163
+ &:hover .module_name
164
+ :color #ddd
165
+
166
+ div.header
167
+ :font-size 80%
168
+ :padding .5em 2%
169
+ :font-family Arial, Helvetica, sans-serif
170
+ :border-bottom 1px solid silver
171
+ .name
172
+ :font-size 1.6em
173
+ :font-family = !title_font
174
+ .type
175
+ :color = !light_text
176
+ :font-size 80%
177
+ :font-variant small-caps
178
+ h1.name
179
+ :font-size 2.2em
180
+ .paths, .last-update, .parent
181
+ :color = !light_text
182
+ .last-update .datetime
183
+ :color = !light_text - 30
184
+ .parent
185
+ :margin-top .3em
186
+ strong
187
+ :font-weight normal
188
+ :color = !light_text - 30
189
+
190
+ #content
191
+ :padding 12px 2%
192
+ div.class &
193
+ :position relative
194
+ :width 72%
195
+
196
+ pre, .method .synopsis
197
+ :font = !code_font
198
+ pre
199
+ :color black
200
+ :background #eee
201
+ :border 1px solid silver
202
+ :padding .5em .8em
203
+ :overflow auto
204
+ p, li, dl
205
+ code, tt
206
+ :font = !code_font
207
+ :background #ffffe3
208
+ :padding 2px 3px
209
+ :line-height 1.4
210
+ h1, h2, h3, h4, h5, h6
211
+ code, tt
212
+ :font-size 1.1em
213
+
214
+ #text
215
+ :position relative
216
+
217
+ #description
218
+ // :max-width 60em
219
+ p
220
+ :margin-top .5em
221
+ h1, h2, h3, h4, h5, h6
222
+ :font-family = !title_font
223
+ h1
224
+ :font-size 2.2em
225
+ :margin-bottom .2em
226
+ :border-bottom 3px double #d8d8d8
227
+ :padding-bottom .1em
228
+ h2
229
+ :font-size 1.8em
230
+ :color = !dark_blue_text
231
+ :margin .8em 0 .3em 0
232
+ h3
233
+ :font-size 1.6em
234
+ :margin .8em 0 .3em 0
235
+ :color = !light_text
236
+ h4
237
+ :font-size 1.4em
238
+ :margin .8em 0 .3em 0
239
+ h5
240
+ :font-size 1.2em
241
+ :margin .8em 0 .3em 0
242
+ :color = !dark_blue_text
243
+ h6
244
+ :font-size 1.0em
245
+ :margin .8em 0 .3em 0
246
+ :color = !light_text
247
+
248
+ #description, .method .description
249
+ ul, ol
250
+ :margin .8em 0
251
+ :padding-left 1.5em
252
+ ol
253
+ :list-style decimal
254
+ li
255
+ :white-space normal
256
+
257
+ #method-list
258
+ :position absolute
259
+ :top 0px
260
+ :right -33%
261
+ :width 28%
262
+ :background #eee
263
+ :border 1px solid silver
264
+ :padding .4em 1%
265
+ :overflow hidden
266
+ h2
267
+ :font-size 1.3em
268
+ h3
269
+ :font-variant small-caps
270
+ :text-transform capitalize
271
+ :font-family = !title_font
272
+ :color #666
273
+ :font-size 1.1em
274
+ ol
275
+ :padding 0 0 .5em .5em
276
+
277
+ #context
278
+ :border-top 1px dashed silver
279
+ :margin-top 1em
280
+ :margin-bottom 1em
281
+
282
+ #context, #section
283
+ h2
284
+ :font = "small-caps 1.2em" !title_font
285
+ :color #444
286
+ :margin 1em 0 .2em 0
287
+
288
+ #methods
289
+ .method
290
+ :border 1px solid silver
291
+ :margin-top .5em
292
+ :background #eee
293
+ .synopsis
294
+ :color black
295
+ :background silver
296
+ :padding .2em 1em
297
+ .name
298
+ :font-weight bold
299
+ a
300
+ :text-decoration none
301
+ .description
302
+ :padding 0 1em
303
+ pre
304
+ :background #f8f8f8
305
+ .source
306
+ :margin .5em 0
307
+ .source-toggle
308
+ :font-size 85%
309
+ :margin-left 1em
310
+ .public-class
311
+ :background #ffffe4
312
+ .public-instance .synopsis
313
+ :color #eee
314
+ :background = !light_link
315
+
316
+ #content .method .source pre
317
+ :background #262626
318
+ :color #ffdead
319
+ :margin 1em
320
+ :padding 0.5em
321
+ :border 1px dashed #999
322
+ :overflow auto
323
+
324
+ .ruby-constant
325
+ :color #7fffd4
326
+ :background transparent
327
+
328
+ .ruby-keyword
329
+ :color #00ffff
330
+ :background transparent
331
+
332
+ .ruby-ivar
333
+ :color #eedd82
334
+ :background transparent
335
+
336
+ .ruby-operator
337
+ :color #00ffee
338
+ :background transparent
339
+
340
+ .ruby-identifier
341
+ :color #ffdead
342
+ :background transparent
343
+
344
+ .ruby-node
345
+ :color #ffa07a
346
+ :background transparent
347
+
348
+ .ruby-comment
349
+ :color #b22222
350
+ :font-weight bold
351
+ :background transparent
352
+
353
+ .ruby-regexp
354
+ :color #ffa07a
355
+ :background transparent
356
+
357
+ .ruby-value
358
+ :color #7fffd4
359
+ :background transparent
@@ -0,0 +1,119 @@
1
+ require 'yaml'
2
+ require 'cgi'
3
+
4
+ module Hanna
5
+ module TemplateHelpers
6
+ protected
7
+
8
+ def link_to(text, url = nil, classname = nil)
9
+ class_attr = classname ? %[ class="#{classname}"] : ''
10
+
11
+ if url
12
+ %[<a href="#{url}"#{class_attr}>#{text}</a>]
13
+ elsif classname
14
+ %[<span#{class_attr}>#{text}</span>]
15
+ else
16
+ text
17
+ end
18
+ end
19
+
20
+ # +method_text+ is in the form of "ago (ActiveSupport::TimeWithZone)".
21
+ def link_to_method(method_text, url = nil, classname = nil)
22
+ method_text =~ /\A(.+) \((.+)\)\Z/
23
+ method_name, module_name = $1, $2
24
+ link_to %Q(<span class="method_name">#{h method_name}</span> <span class="module_name">(#{h module_name})</span>), url, classname
25
+ end
26
+
27
+ def read(*names)
28
+ RDoc::Generator::HTML::HANNA.read(*names)
29
+ end
30
+
31
+ # We need to suppress warnings before calling into HAML because
32
+ # HAML has lots of uninitialized instance variable accesses.
33
+ def silence_warnings
34
+ save = $-w
35
+ $-w = false
36
+
37
+ begin
38
+ yield
39
+ ensure
40
+ $-w = save
41
+ end
42
+ end
43
+ module_function :silence_warnings
44
+
45
+ def debug(text)
46
+ "<pre>#{h YAML::dump(text)}</pre>"
47
+ end
48
+
49
+ def h(html)
50
+ CGI::escapeHTML(html)
51
+ end
52
+
53
+ # +entries+ is an array of hashes, each which has a "name" and "href" element.
54
+ # An entry name is in the form of "ago (ActiveSupport::TimeWithZone)".
55
+ # +entries+ must be already sorted by name.
56
+ def build_javascript_search_index(entries)
57
+ result = "var search_index = [\n"
58
+ entries.each do |entry|
59
+ entry[:name] =~ /\A(.+) \((.+)\)\Z/
60
+ method_name, module_name = $1, $2
61
+ html = link_to_method(entry[:name], entry[:href])
62
+ result << " { method: '#{method_name.downcase}', " <<
63
+ "module: '#{module_name.downcase}', " <<
64
+ "html: '#{html}' },\n"
65
+ end
66
+ result << "]"
67
+ result
68
+ end
69
+
70
+ def methods_from_sections(sections)
71
+ sections.inject(Hash.new {|h, k| h[k] = []}) do |methods, section|
72
+ section[:method_list].each do |ml|
73
+ methods["#{ml[:type]} #{ml[:category]}".downcase].concat ml[:methods]
74
+ end if section[:method_list]
75
+ methods
76
+ end
77
+ end
78
+
79
+ def make_class_tree(entries)
80
+ entries.inject({}) do |tree, entry|
81
+ if entry[:href]
82
+ leaf = entry[:name].split('::').inject(tree) do |branch, klass|
83
+ branch[klass] ||= {}
84
+ end
85
+ leaf['_href'] = entry[:href]
86
+ end
87
+ tree
88
+ end
89
+ end
90
+
91
+ def render_class_tree(tree, parent = nil)
92
+ parent = parent + '::' if parent
93
+ tree.keys.sort.inject('') do |out, name|
94
+ unless name == '_href'
95
+ subtree = tree[name]
96
+ text = parent ? %[<span class="parent">#{parent}</span>#{name}] : name
97
+ out << '<li>'
98
+ out << (subtree['_href'] ? link_to(text, subtree['_href']) : %[<span class="nodoc">#{text}</span>])
99
+ if subtree.keys.size > 1 || (subtree.keys.size == 1 && !subtree['_href'])
100
+ out << "\n<ol>" << render_class_tree(subtree, parent.to_s + name) << "\n</ol>"
101
+ end
102
+ out << '</li>'
103
+ end
104
+ out
105
+ end
106
+ end
107
+
108
+ # primarily for removing leading whitespace in <pre> tags
109
+ def sanitize_code_blocks(text)
110
+ text.gsub(/<pre>(.+?)<\/pre>/m) do
111
+ code = $1.sub(/^\s*\n/, '')
112
+ indent = code.gsub(/\n[ \t]*\n/, "\n").scan(/^ */).map{ |i| i.size }.min
113
+ code.gsub!(/^#{' ' * indent}/, '') if indent > 0
114
+
115
+ "<pre>#{code}</pre>"
116
+ end
117
+ end
118
+ end
119
+ end