hanna 0.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +102 -0
- data/Rakefile +4 -0
- data/bin/hanna +81 -0
- data/lib/hanna.rb +1 -0
- data/lib/hanna/hanna.rb +48 -0
- data/lib/hanna/rdoctask.rb +42 -0
- data/lib/hanna/template_files/class_index.haml +3 -0
- data/lib/hanna/template_files/file_index.haml +12 -0
- data/lib/hanna/template_files/index.haml +11 -0
- data/lib/hanna/template_files/layout.haml +34 -0
- data/lib/hanna/template_files/method_index.haml +13 -0
- data/lib/hanna/template_files/method_list.haml +37 -0
- data/lib/hanna/template_files/method_search.js +63 -0
- data/lib/hanna/template_files/page.haml +50 -0
- data/lib/hanna/template_files/prototype-1.6.0.3.js +4320 -0
- data/lib/hanna/template_files/sections.haml +83 -0
- data/lib/hanna/template_files/styles.sass +364 -0
- data/lib/hanna/template_helpers.rb +119 -0
- data/lib/hanna/template_page_patch.rb +38 -0
- data/lib/hanna/version.rb +19 -0
- data/lib/rubygems_plugin.rb +28 -0
- metadata +104 -0
@@ -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~ sanitize_code_blocks(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,364 @@
|
|
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
|
+
|
167
|
+
#attribute-list
|
168
|
+
.context-item-name
|
169
|
+
:font-weight bold
|
170
|
+
|
171
|
+
div.header
|
172
|
+
:font-size 80%
|
173
|
+
:padding .5em 2%
|
174
|
+
:font-family Arial, Helvetica, sans-serif
|
175
|
+
:border-bottom 1px solid silver
|
176
|
+
.name
|
177
|
+
:font-size 1.6em
|
178
|
+
:font-family = !title_font
|
179
|
+
.type
|
180
|
+
:color = !light_text
|
181
|
+
:font-size 80%
|
182
|
+
:font-variant small-caps
|
183
|
+
h1.name
|
184
|
+
:font-size 2.2em
|
185
|
+
.paths, .last-update, .parent
|
186
|
+
:color = !light_text
|
187
|
+
.last-update .datetime
|
188
|
+
:color = !light_text - 30
|
189
|
+
.parent
|
190
|
+
:margin-top .3em
|
191
|
+
strong
|
192
|
+
:font-weight normal
|
193
|
+
:color = !light_text - 30
|
194
|
+
|
195
|
+
#content
|
196
|
+
:padding 12px 2%
|
197
|
+
div.class &
|
198
|
+
:position relative
|
199
|
+
:width 72%
|
200
|
+
|
201
|
+
pre, .method .synopsis
|
202
|
+
:font = !code_font
|
203
|
+
pre
|
204
|
+
:color black
|
205
|
+
:background #eee
|
206
|
+
:border 1px solid silver
|
207
|
+
:padding .5em .8em
|
208
|
+
:overflow auto
|
209
|
+
p, li, dl
|
210
|
+
code, tt
|
211
|
+
:font = !code_font
|
212
|
+
:background #ffffe3
|
213
|
+
:padding 2px 3px
|
214
|
+
:line-height 1.4
|
215
|
+
h1, h2, h3, h4, h5, h6
|
216
|
+
code, tt
|
217
|
+
:font-size 1.1em
|
218
|
+
|
219
|
+
#text
|
220
|
+
:position relative
|
221
|
+
|
222
|
+
#description
|
223
|
+
// :max-width 60em
|
224
|
+
p
|
225
|
+
:margin-top .5em
|
226
|
+
h1, h2, h3, h4, h5, h6
|
227
|
+
:font-family = !title_font
|
228
|
+
h1
|
229
|
+
:font-size 2.2em
|
230
|
+
:margin-bottom .2em
|
231
|
+
:border-bottom 3px double #d8d8d8
|
232
|
+
:padding-bottom .1em
|
233
|
+
h2
|
234
|
+
:font-size 1.8em
|
235
|
+
:color = !dark_blue_text
|
236
|
+
:margin .8em 0 .3em 0
|
237
|
+
h3
|
238
|
+
:font-size 1.6em
|
239
|
+
:margin .8em 0 .3em 0
|
240
|
+
:color = !light_text
|
241
|
+
h4
|
242
|
+
:font-size 1.4em
|
243
|
+
:margin .8em 0 .3em 0
|
244
|
+
h5
|
245
|
+
:font-size 1.2em
|
246
|
+
:margin .8em 0 .3em 0
|
247
|
+
:color = !dark_blue_text
|
248
|
+
h6
|
249
|
+
:font-size 1.0em
|
250
|
+
:margin .8em 0 .3em 0
|
251
|
+
:color = !light_text
|
252
|
+
|
253
|
+
#description, .method .description
|
254
|
+
ul, ol
|
255
|
+
:margin .8em 0
|
256
|
+
:padding-left 1.5em
|
257
|
+
ol
|
258
|
+
:list-style decimal
|
259
|
+
li
|
260
|
+
:white-space normal
|
261
|
+
|
262
|
+
#method-list
|
263
|
+
:position absolute
|
264
|
+
:top 0px
|
265
|
+
:right -33%
|
266
|
+
:width 28%
|
267
|
+
:background #eee
|
268
|
+
:border 1px solid silver
|
269
|
+
:padding .4em 1%
|
270
|
+
:overflow hidden
|
271
|
+
h2
|
272
|
+
:font-size 1.3em
|
273
|
+
h3
|
274
|
+
:font-variant small-caps
|
275
|
+
:text-transform capitalize
|
276
|
+
:font-family = !title_font
|
277
|
+
:color #666
|
278
|
+
:font-size 1.1em
|
279
|
+
ol
|
280
|
+
:padding 0 0 .5em .5em
|
281
|
+
|
282
|
+
#context
|
283
|
+
:border-top 1px dashed silver
|
284
|
+
:margin-top 1em
|
285
|
+
:margin-bottom 1em
|
286
|
+
|
287
|
+
#context, #section
|
288
|
+
h2
|
289
|
+
:font = "small-caps 1.2em" !title_font
|
290
|
+
:color #444
|
291
|
+
:margin 1em 0 .2em 0
|
292
|
+
|
293
|
+
#methods
|
294
|
+
.method
|
295
|
+
:border 1px solid silver
|
296
|
+
:margin-top .5em
|
297
|
+
:background #eee
|
298
|
+
.synopsis
|
299
|
+
:color black
|
300
|
+
:background silver
|
301
|
+
:padding .2em 1em
|
302
|
+
.name
|
303
|
+
:font-weight bold
|
304
|
+
a
|
305
|
+
:text-decoration none
|
306
|
+
.description
|
307
|
+
:padding 0 1em
|
308
|
+
pre
|
309
|
+
:background #f8f8f8
|
310
|
+
.source
|
311
|
+
:margin .5em 0
|
312
|
+
.source-toggle
|
313
|
+
:font-size 85%
|
314
|
+
:margin-left 1em
|
315
|
+
.public-class
|
316
|
+
:background #ffffe4
|
317
|
+
.public-instance .synopsis
|
318
|
+
:color #eee
|
319
|
+
:background = !light_link
|
320
|
+
|
321
|
+
#content .method .source pre
|
322
|
+
:background #262626
|
323
|
+
:color #ffdead
|
324
|
+
:margin 1em
|
325
|
+
:padding 0.5em
|
326
|
+
:border 1px dashed #999
|
327
|
+
:overflow auto
|
328
|
+
|
329
|
+
.ruby-constant
|
330
|
+
:color #7fffd4
|
331
|
+
:background transparent
|
332
|
+
|
333
|
+
.ruby-keyword
|
334
|
+
:color #00ffff
|
335
|
+
:background transparent
|
336
|
+
|
337
|
+
.ruby-ivar
|
338
|
+
:color #eedd82
|
339
|
+
:background transparent
|
340
|
+
|
341
|
+
.ruby-operator
|
342
|
+
:color #00ffee
|
343
|
+
:background transparent
|
344
|
+
|
345
|
+
.ruby-identifier
|
346
|
+
:color #ffdead
|
347
|
+
:background transparent
|
348
|
+
|
349
|
+
.ruby-node
|
350
|
+
:color #ffa07a
|
351
|
+
:background transparent
|
352
|
+
|
353
|
+
.ruby-comment
|
354
|
+
:color #b22222
|
355
|
+
:font-weight bold
|
356
|
+
:background transparent
|
357
|
+
|
358
|
+
.ruby-regexp
|
359
|
+
:color #ffa07a
|
360
|
+
:background transparent
|
361
|
+
|
362
|
+
.ruby-value
|
363
|
+
:color #7fffd4
|
364
|
+
: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="%s"' % 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">%s</span>%s' % [parent, 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
|