mislav-hanna 0.1.1 → 0.1.2
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 +24 -7
- data/bin/hanna +46 -6
- data/lib/hanna/hanna.rb +7 -8
- data/lib/hanna/rdoctask.rb +4 -3
- data/lib/hanna/template_files/file_index.haml +11 -2
- data/lib/hanna/template_files/index.haml +1 -1
- data/lib/hanna/template_files/page.haml +11 -7
- data/lib/hanna/template_files/sections.haml +17 -17
- data/lib/hanna/template_files/styles.sass +75 -26
- data/lib/hanna/template_helpers.rb +66 -0
- data/lib/hanna/template_page_patch.rb +5 -54
- metadata +6 -4
data/README.markdown
CHANGED
@@ -2,18 +2,31 @@
|
|
2
2
|
|
3
3
|
Hanna is an RDoc template that scales. It's implemented in Haml, making the
|
4
4
|
sources clean and readable. It's built with simplicity, beauty and ease of
|
5
|
-
browsing in mind.
|
5
|
+
browsing in mind. (See more in [the wiki][wiki].)
|
6
6
|
|
7
|
-
Hanna is available from [GitHub][]:
|
7
|
+
Hanna was made by [Mislav][] and is available from [GitHub][]:
|
8
8
|
|
9
9
|
gem install mislav-hanna
|
10
10
|
|
11
|
-
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
After installing, you have three options. You can use the command-line tool:
|
12
15
|
|
13
16
|
hanna -h
|
14
17
|
|
15
|
-
For repeated generation of API docs, it's better to set up a Rake task.
|
16
|
-
an
|
18
|
+
For repeated generation of API docs, it's better to set up a Rake task. If you
|
19
|
+
already have an `RDocTask` set up, the only thing you need to change is this:
|
20
|
+
|
21
|
+
# replace this:
|
22
|
+
require 'rake/rdoctask'
|
23
|
+
# with this:
|
24
|
+
require 'hanna/rdoctask'
|
25
|
+
|
26
|
+
Tip: you can do this in the Rakefile of your Rails project before running `rake
|
27
|
+
doc:rails`.
|
28
|
+
|
29
|
+
Here is an example of a task for the [will_paginate library][wp]:
|
17
30
|
|
18
31
|
# instead of 'rake/rdoctask':
|
19
32
|
require 'hanna/rdoctask'
|
@@ -35,7 +48,10 @@ an example for [will_paginate][]:
|
|
35
48
|
|
36
49
|
Either way, it's the same as using RDoc.
|
37
50
|
|
38
|
-
Hanna
|
51
|
+
The last thing you can do with Hanna is generate documentation for installed
|
52
|
+
gems. This is a replacement for the "gem rdoc" command.
|
53
|
+
|
54
|
+
[sudo] hanna --gems haml will_paginate
|
39
55
|
|
40
56
|
## A work in progress
|
41
57
|
|
@@ -59,7 +75,8 @@ Don't like something? Think you can design better? (You probably can.)
|
|
59
75
|
This is git. I welcome all submissions towards my goal.
|
60
76
|
|
61
77
|
|
78
|
+
[wiki]: http://github.com/mislav/hanna/wikis/home "Hanna wiki"
|
62
79
|
[GitHub]: http://gems.github.com/ "GitHub gem source"
|
63
|
-
[
|
80
|
+
[wp]: http://github.com/mislav/will_paginate
|
64
81
|
[Mislav]: http://mislav.caboo.se/ "Mislav Marohnić"
|
65
82
|
[Allison]: http://blog.evanweaver.com/files/doc/fauna/allison/ "A modern, pretty RDoc template"
|
data/bin/hanna
CHANGED
@@ -2,15 +2,24 @@
|
|
2
2
|
if ARGV.size == 1 and ARGV.first == '-h'
|
3
3
|
puts <<-HELP
|
4
4
|
Hanna -- a better RDoc template
|
5
|
-
|
5
|
+
Synopsis:
|
6
|
+
hanna [options] [file names...]
|
7
|
+
[sudo] hanna --gems [gem names...]
|
8
|
+
|
9
|
+
Example usage:
|
6
10
|
|
7
11
|
hanna lib/**/*.rb
|
8
12
|
|
9
|
-
Hanna passes all arguments to RDoc. To find more about RDoc options,
|
10
|
-
|
13
|
+
Hanna passes all arguments to RDoc. To find more about RDoc options, see
|
14
|
+
"rdoc -h". Default options are:
|
11
15
|
|
12
16
|
-o doc --inline-source --charset=UTF-8
|
13
17
|
|
18
|
+
The second form, with the "--gems" argument, serves the same purpose as
|
19
|
+
the "gem rdoc" command: it generates documentation for installed gems.
|
20
|
+
When no gem names are given, "hanna --gems" will install docs for EACH of
|
21
|
+
the gems, which can, uh, take a little while.
|
22
|
+
|
14
23
|
HELP
|
15
24
|
exit 0
|
16
25
|
end
|
@@ -33,9 +42,40 @@ require 'hanna/rdoc_patch'
|
|
33
42
|
options = []
|
34
43
|
|
35
44
|
options << '-T' << 'hanna/hanna.rb'
|
36
|
-
options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
|
37
45
|
options << '--inline-source' << '--charset=UTF-8'
|
38
46
|
|
39
|
-
|
47
|
+
if ARGV.first == '--gems'
|
48
|
+
require 'rubygems/doc_manager'
|
49
|
+
Gem::DocManager.configured_args = options
|
50
|
+
|
51
|
+
gem_names = ARGV.dup
|
52
|
+
gem_names.shift
|
53
|
+
|
54
|
+
unless gem_names.empty?
|
55
|
+
specs = gem_names.inject([]) do |arr, name|
|
56
|
+
found = Gem::SourceIndex.from_installed_gems.search(name)
|
57
|
+
spec = found.sort_by {|s| s.version }.last
|
58
|
+
arr << spec if spec
|
59
|
+
arr
|
60
|
+
end
|
61
|
+
else
|
62
|
+
specs = Gem::SourceIndex.from_installed_gems.inject({}) do |all, pair|
|
63
|
+
full_name, spec = pair
|
64
|
+
if spec.has_rdoc? and (!all[spec.name] or spec.version > all[spec.name].version)
|
65
|
+
all[spec.name] = spec
|
66
|
+
end
|
67
|
+
all
|
68
|
+
end
|
69
|
+
specs = specs.values
|
70
|
+
puts "Hanna is installing documentation for #{specs.size} gem#{specs.size > 1 ? 's' : ''} ..."
|
71
|
+
end
|
72
|
+
|
73
|
+
specs.each do |spec|
|
74
|
+
Gem::DocManager.new(spec).generate_rdoc
|
75
|
+
end
|
76
|
+
else
|
77
|
+
options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
|
78
|
+
options.concat ARGV
|
40
79
|
|
41
|
-
RDoc::RDoc.new.document(options)
|
80
|
+
RDoc::RDoc.new.document(options)
|
81
|
+
end
|
data/lib/hanna/hanna.rb
CHANGED
@@ -1,16 +1,15 @@
|
|
1
|
+
# = A better RDoc HTML template
|
2
|
+
#
|
3
|
+
# Authors: Mislav Marohnić <mislav.marohnic@gmail.com>
|
4
|
+
# Tony Strauss (http://github.com/DesigningPatterns)
|
5
|
+
# Michael Granger <ged@FaerieMUD.org>, who had maintained the original RDoc template
|
6
|
+
|
1
7
|
require 'haml'
|
2
8
|
require 'sass'
|
3
9
|
require 'rdoc/generator/html'
|
4
10
|
require 'hanna/template_page_patch'
|
5
11
|
|
6
|
-
|
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
|
12
|
+
module RDoc::Generator::HTML::HANNA
|
14
13
|
class << self
|
15
14
|
def dir
|
16
15
|
@dir ||= File.join File.dirname(__FILE__), 'template_files'
|
data/lib/hanna/rdoctask.rb
CHANGED
@@ -10,8 +10,9 @@ Rake::RDocTask.class_eval do
|
|
10
10
|
unless @template and @template != 'html'
|
11
11
|
@template = File.dirname(__FILE__) + '/hanna'
|
12
12
|
end
|
13
|
+
# inline source and UTF-8 are defaults:
|
13
14
|
options << '--inline-source' unless options.include? '--inline-source' or options.include? '-S'
|
14
|
-
options << '--charset=UTF-8' if options.grep(/^(--charset
|
15
|
+
options << '--charset=UTF-8' if options.grep(/^(--charset\b|-c\b)/).empty?
|
15
16
|
|
16
17
|
desc "Build the HTML documentation"
|
17
18
|
task name
|
@@ -32,9 +33,9 @@ Rake::RDocTask.class_eval do
|
|
32
33
|
rm_r @rdoc_dir rescue nil
|
33
34
|
|
34
35
|
begin
|
35
|
-
gem 'rdoc', '~> 2.
|
36
|
+
gem 'rdoc', '~> 2.1.0'
|
36
37
|
rescue Gem::LoadError
|
37
|
-
$stderr.puts "Couldn't load RDoc 2.
|
38
|
+
$stderr.puts "Couldn't load RDoc 2.1 gem"
|
38
39
|
end
|
39
40
|
require 'rdoc/rdoc'
|
40
41
|
require 'hanna/rdoc_patch'
|
@@ -1,4 +1,13 @@
|
|
1
1
|
%h1= values["list_title"]
|
2
|
-
|
2
|
+
- type = values["list_title"].downcase
|
3
|
+
- any_hidden = false
|
4
|
+
|
5
|
+
%ol#index-entries{ :class => type }
|
3
6
|
- for entry in values["entries"]
|
4
|
-
|
7
|
+
- hide = type == 'files' && entry['name'] =~ /\.rb$/
|
8
|
+
- any_hidden = true if hide
|
9
|
+
%li{ :class => hide ? 'other' : nil }= link_to entry['name'], entry['href']
|
10
|
+
|
11
|
+
- if any_hidden
|
12
|
+
%li
|
13
|
+
%a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
|
@@ -3,7 +3,7 @@
|
|
3
3
|
%head
|
4
4
|
%title= values["title"]
|
5
5
|
%meta{ :content => "text/html; charset=#{values['charset']}", "http-equiv" => "Content-Type" }
|
6
|
-
%frameset{ :cols => "20%, *"
|
6
|
+
%frameset{ :cols => "20%, *" }
|
7
7
|
%frameset{ :rows => "15%, 35%, 50%" }
|
8
8
|
%frame{ :name => "Files", :title => "Files", :src => "fr_file_index.html" }
|
9
9
|
%frame{ :name => "Classes", :src => "fr_class_index.html" }
|
@@ -20,11 +20,14 @@
|
|
20
20
|
== (#{link_to 'view online', values["cvsurl"]})
|
21
21
|
- else
|
22
22
|
%ol.paths
|
23
|
-
-
|
24
|
-
%li
|
23
|
+
- values["infiles"].each_with_index do |file, index|
|
24
|
+
%li{ :class => index > 0 ? 'other' : nil }
|
25
25
|
= link_to file["full_path"], file["full_path_url"]
|
26
26
|
- if file["cvsurl"]
|
27
27
|
== (#{link_to 'view online', file["cvsurl"]})
|
28
|
+
- if values["infiles"].size > 1
|
29
|
+
%li
|
30
|
+
%a.show{ :href => '#', :onclick => 'this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false' } show all
|
28
31
|
|
29
32
|
- if values["parent"] then
|
30
33
|
.parent
|
@@ -39,8 +42,9 @@
|
|
39
42
|
#content
|
40
43
|
- if values["diagram"]
|
41
44
|
#diagram= values["diagram"]
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
45
|
+
|
46
|
+
#text
|
47
|
+
- if values["description"]
|
48
|
+
#description~ values["description"]
|
49
|
+
|
50
|
+
= yield
|
@@ -4,17 +4,17 @@
|
|
4
4
|
%h2= link_to section["sectitle"], section["secsequence"]
|
5
5
|
- if section["seccomment"]
|
6
6
|
.section-comment= section["seccomment"]
|
7
|
-
- if
|
7
|
+
- if section["classlist"]
|
8
8
|
#class-list
|
9
9
|
%h3 Classes and Modules
|
10
|
-
=
|
10
|
+
= section["classlist"]
|
11
11
|
|
12
|
-
- if
|
12
|
+
- if section["constants"]
|
13
13
|
#constants-list
|
14
14
|
%h3.section-bar Constants
|
15
15
|
.name-list
|
16
16
|
%table{ :summary => "Constants" }
|
17
|
-
- for const in
|
17
|
+
- for const in section["constants"]
|
18
18
|
%tr.top-aligned-row.context-row
|
19
19
|
%td.context-item-name
|
20
20
|
= const["name"]
|
@@ -22,48 +22,48 @@
|
|
22
22
|
\=
|
23
23
|
%td.context-item-value
|
24
24
|
= const["value"]
|
25
|
-
- if
|
25
|
+
- if const["desc"] then
|
26
26
|
%td{ :width => "3em" }
|
27
27
|
|
28
28
|
%td.context-item-desc
|
29
29
|
= const["desc"]
|
30
30
|
|
31
|
-
- if
|
31
|
+
- if section["aliases"]
|
32
32
|
#aliases-list
|
33
33
|
%h3.section-bar External Aliases
|
34
34
|
.name-list
|
35
35
|
%table{ :summary => "aliases" }
|
36
|
-
- for alia in
|
36
|
+
- for alia in section["aliases"]
|
37
37
|
%tr.top-aligned-row.context-row
|
38
38
|
%td.context-item-name
|
39
|
-
=
|
39
|
+
= alia["old_name"]
|
40
40
|
%td
|
41
41
|
\->
|
42
42
|
%td.context-item-value
|
43
|
-
=
|
44
|
-
- if
|
43
|
+
= alia["new_name"]
|
44
|
+
- if alia["desc"] then
|
45
45
|
%tr.top-aligned-row.context-row
|
46
46
|
%td
|
47
47
|
|
48
48
|
%td.context-item-desc{ :colspan => "2" }
|
49
|
-
=
|
49
|
+
= alia["desc"]
|
50
50
|
|
51
|
-
- if
|
51
|
+
- if section["attributes"]
|
52
52
|
#attribute-list
|
53
53
|
%h3.section-bar Attributes
|
54
54
|
.name-list
|
55
55
|
%table
|
56
|
-
- for attr in
|
56
|
+
- for attr in section["attributes"]
|
57
57
|
%tr.top-aligned-row.context-row
|
58
58
|
%td.context-item-name
|
59
|
-
=
|
60
|
-
- if
|
59
|
+
= attr["name"]
|
60
|
+
- if attr["rw"] then
|
61
61
|
%td.context-item-value
|
62
|
-
= "[#{
|
62
|
+
= "[#{attr['rw']}]"
|
63
63
|
- else
|
64
64
|
%td.context-item-value
|
65
65
|
%td.context-item-desc
|
66
|
-
=
|
66
|
+
= attr["a_desc"]
|
67
67
|
|
68
68
|
- if section["method_list"]
|
69
69
|
#methods
|
@@ -1,9 +1,12 @@
|
|
1
|
-
!title_font =
|
2
|
-
!
|
1
|
+
!title_font = Georgia, serif
|
2
|
+
!code_font_family = Monaco, "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace
|
3
|
+
!code_font_size = 14px
|
4
|
+
!code_font = !code_font_size !code_font_family
|
3
5
|
|
4
6
|
!light_link = #369
|
5
7
|
!link = !light_link - 40
|
6
8
|
!light_text = #666
|
9
|
+
!dark_blue_text = #0E3062
|
7
10
|
|
8
11
|
html, body
|
9
12
|
:height 100%
|
@@ -19,11 +22,9 @@ body
|
|
19
22
|
:height auto !important
|
20
23
|
:height 100%
|
21
24
|
:margin 0 auto -43px
|
22
|
-
:border-left 1px solid gray
|
23
25
|
#footer-push
|
24
26
|
:height 43px
|
25
27
|
div.header, #footer
|
26
|
-
:font-size 80%
|
27
28
|
:background #eee
|
28
29
|
#footer
|
29
30
|
:border-top 1px solid silver
|
@@ -32,6 +33,7 @@ div.header, #footer
|
|
32
33
|
:line-height 30px
|
33
34
|
:text-align center
|
34
35
|
:font-variant small-caps
|
36
|
+
:font-size 95%
|
35
37
|
|
36
38
|
// self-clearing
|
37
39
|
.clearing
|
@@ -61,7 +63,7 @@ a
|
|
61
63
|
:color = !light_link
|
62
64
|
&:hover
|
63
65
|
:color #eee
|
64
|
-
h1, h2, h3
|
66
|
+
h1, h2, h3, h4, h5, h6
|
65
67
|
a
|
66
68
|
:color = !link
|
67
69
|
|
@@ -71,7 +73,12 @@ ol
|
|
71
73
|
:list-style none
|
72
74
|
li
|
73
75
|
:margin-left 0
|
74
|
-
white-space
|
76
|
+
:white-space nowrap
|
77
|
+
&.other
|
78
|
+
:display none
|
79
|
+
ol.expanded li.other
|
80
|
+
:display list-item
|
81
|
+
|
75
82
|
table
|
76
83
|
:margin-bottom 1em
|
77
84
|
:font-size 1em
|
@@ -86,6 +93,17 @@ table
|
|
86
93
|
tr
|
87
94
|
:border-bottom 1px solid silver
|
88
95
|
|
96
|
+
#index, div.header
|
97
|
+
a.show
|
98
|
+
:text-decoration underline
|
99
|
+
:font-style italic
|
100
|
+
:color = !light_text
|
101
|
+
&:after
|
102
|
+
:content " ..."
|
103
|
+
&:hover
|
104
|
+
:color black
|
105
|
+
:background #ffe
|
106
|
+
|
89
107
|
#index
|
90
108
|
:font 85%/1.2 Arial, Helvetica, sans-serif
|
91
109
|
a
|
@@ -93,10 +111,9 @@ table
|
|
93
111
|
h1
|
94
112
|
:padding .2em .5em .1em
|
95
113
|
:background #ccc
|
96
|
-
:font = "small-caps 1.
|
114
|
+
:font = "small-caps 1.2em" !title_font
|
97
115
|
:color #333
|
98
116
|
:border-bottom 1px solid gray
|
99
|
-
:border-top 1px solid #aaa
|
100
117
|
ol
|
101
118
|
:padding .4em .5em
|
102
119
|
li
|
@@ -105,15 +122,16 @@ table
|
|
105
122
|
:font-size 1.1em
|
106
123
|
ol
|
107
124
|
:padding 0
|
108
|
-
span.
|
125
|
+
span.nodoc
|
109
126
|
:display none
|
110
|
-
.
|
127
|
+
span.nodoc, a
|
111
128
|
:font-weight bold
|
112
129
|
.parent
|
113
130
|
:font-weight normal
|
114
131
|
|
115
132
|
div.header
|
116
|
-
:
|
133
|
+
:font-size 80%
|
134
|
+
:padding .5em 2%
|
117
135
|
:font-family Arial, Helvetica, sans-serif
|
118
136
|
:border-bottom 1px solid silver
|
119
137
|
.name
|
@@ -127,8 +145,6 @@ div.header
|
|
127
145
|
:font-size 2.2em
|
128
146
|
.paths, .last-update, .parent
|
129
147
|
:color = !light_text
|
130
|
-
ol.paths
|
131
|
-
:padding-left .5em
|
132
148
|
.last-update .datetime
|
133
149
|
:color = !light_text - 30
|
134
150
|
.parent
|
@@ -138,30 +154,37 @@ div.header
|
|
138
154
|
:color = !light_text - 30
|
139
155
|
|
140
156
|
#content
|
141
|
-
:padding 12px
|
157
|
+
:padding 12px 2%
|
142
158
|
div.class &
|
143
159
|
:position relative
|
144
|
-
:width
|
160
|
+
:width 72%
|
145
161
|
|
146
162
|
pre, .method .synopsis
|
147
|
-
:font =
|
163
|
+
:font = !code_font
|
148
164
|
pre
|
149
165
|
:color black
|
150
166
|
:background #eee
|
151
167
|
:border 1px solid silver
|
152
168
|
:padding 0 .5em .8em .5em
|
153
169
|
:overflow auto
|
154
|
-
p, li
|
170
|
+
p, li, dl
|
155
171
|
code, tt
|
156
|
-
:font =
|
172
|
+
:font = !code_font
|
157
173
|
:background #ffffe3
|
158
174
|
:padding 2px 3px
|
175
|
+
:line-height 1.4
|
176
|
+
h1, h2, h3, h4, h5, h6
|
177
|
+
code, tt
|
178
|
+
:font-size 1.1em
|
179
|
+
|
180
|
+
#text
|
181
|
+
:position relative
|
159
182
|
|
160
183
|
#description
|
161
184
|
// :max-width 60em
|
162
185
|
p
|
163
186
|
:margin-top .5em
|
164
|
-
h1, h2, h3
|
187
|
+
h1, h2, h3, h4, h5, h6
|
165
188
|
:font-family = !title_font
|
166
189
|
h1
|
167
190
|
:font-size 2.2em
|
@@ -170,21 +193,41 @@ div.header
|
|
170
193
|
:padding-bottom .1em
|
171
194
|
h2
|
172
195
|
:font-size 1.8em
|
173
|
-
:color
|
196
|
+
:color = !dark_blue_text
|
174
197
|
:margin .8em 0 .3em 0
|
175
198
|
h3
|
176
199
|
:font-size 1.6em
|
177
200
|
:margin .8em 0 .3em 0
|
178
201
|
:color = !light_text
|
202
|
+
h4
|
203
|
+
:font-size 1.4em
|
204
|
+
:margin .8em 0 .3em 0
|
205
|
+
h5
|
206
|
+
:font-size 1.2em
|
207
|
+
:margin .8em 0 .3em 0
|
208
|
+
:color = !dark_blue_text
|
209
|
+
h6
|
210
|
+
:font-size 1.0em
|
211
|
+
:margin .8em 0 .3em 0
|
212
|
+
:color = !light_text
|
213
|
+
|
214
|
+
#description, .method .description
|
215
|
+
ul, ol
|
216
|
+
:margin .8em 0
|
217
|
+
:padding-left 1.5em
|
218
|
+
ol
|
219
|
+
:list-style decimal
|
220
|
+
li
|
221
|
+
:white-space wrap
|
179
222
|
|
180
223
|
#method-list
|
181
224
|
:position absolute
|
182
|
-
:top
|
183
|
-
:right -
|
184
|
-
:width
|
225
|
+
:top 0px
|
226
|
+
:right -33%
|
227
|
+
:width 28%
|
185
228
|
:background #eee
|
186
229
|
:border 1px solid silver
|
187
|
-
:padding .
|
230
|
+
:padding .4em 1%
|
188
231
|
:overflow hidden
|
189
232
|
h2
|
190
233
|
:font-size 1.3em
|
@@ -212,6 +255,10 @@ div.header
|
|
212
255
|
:font = "small-caps 1.2em" !title_font
|
213
256
|
:color #444
|
214
257
|
:margin 1em 0 .2em 0
|
258
|
+
h4
|
259
|
+
:font = "1.1em" !title_font
|
260
|
+
:color = !dark_blue_text
|
261
|
+
:margin 1em 0 .2em 0
|
215
262
|
|
216
263
|
.method
|
217
264
|
:border 1px solid silver
|
@@ -221,7 +268,6 @@ div.header
|
|
221
268
|
:color black
|
222
269
|
:background silver
|
223
270
|
:padding .2em 1em
|
224
|
-
:font-size 16px
|
225
271
|
.name
|
226
272
|
:font-weight bold
|
227
273
|
a
|
@@ -236,7 +282,10 @@ div.header
|
|
236
282
|
:font-size 85%
|
237
283
|
:margin-left 1em
|
238
284
|
.public-class
|
239
|
-
:background #
|
285
|
+
:background #ffffe4
|
286
|
+
.public-instance .synopsis
|
287
|
+
:color #eee
|
288
|
+
:background = !light_link
|
240
289
|
|
241
290
|
#content .method .source pre
|
242
291
|
:background #262626
|
@@ -0,0 +1,66 @@
|
|
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
|
+
def debug(text)
|
21
|
+
"<pre>#{h YAML::dump(text)}</pre>"
|
22
|
+
end
|
23
|
+
|
24
|
+
def h(html)
|
25
|
+
CGI::escapeHTML html
|
26
|
+
end
|
27
|
+
|
28
|
+
def methods_from_sections(sections)
|
29
|
+
sections.inject(Hash.new {|h, k| h[k] = []}) do |methods, section|
|
30
|
+
section['method_list'].each do |ml|
|
31
|
+
methods["#{ml['type']} #{ml['category']}".downcase].concat ml['methods']
|
32
|
+
end if section['method_list']
|
33
|
+
methods
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def make_class_tree(entries)
|
38
|
+
entries.inject({}) do |tree, entry|
|
39
|
+
if entry['href']
|
40
|
+
leaf = entry['name'].split('::').inject(tree) do |branch, klass|
|
41
|
+
branch[klass] ||= {}
|
42
|
+
end
|
43
|
+
leaf['_href'] = entry['href']
|
44
|
+
end
|
45
|
+
tree
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def render_class_tree(tree, parent = nil)
|
50
|
+
parent = parent + '::' if parent
|
51
|
+
tree.keys.sort.inject('') do |out, name|
|
52
|
+
unless name == '_href'
|
53
|
+
subtree = tree[name]
|
54
|
+
text = parent ? %[<span class="parent">#{parent}</span>#{name}] : name
|
55
|
+
out << '<li>'
|
56
|
+
out << (subtree['_href'] ? link_to(text, subtree['_href']) : %[<span class="nodoc">#{text}</span>])
|
57
|
+
if subtree.keys.size > 1
|
58
|
+
out << "\n<ol>" << render_class_tree(subtree, parent.to_s + name) << "\n</ol>"
|
59
|
+
end
|
60
|
+
out << '</li>'
|
61
|
+
end
|
62
|
+
out
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -1,7 +1,10 @@
|
|
1
|
-
require '
|
2
|
-
require 'cgi'
|
1
|
+
require 'hanna/template_helpers'
|
3
2
|
|
4
3
|
RDoc::TemplatePage.class_eval do
|
4
|
+
|
5
|
+
include Hanna::TemplateHelpers
|
6
|
+
|
7
|
+
# overwrite the original method
|
5
8
|
def write_html_on(io, values)
|
6
9
|
result = @templates.reverse.inject(nil) do |previous, template|
|
7
10
|
case template
|
@@ -24,58 +27,6 @@ RDoc::TemplatePage.class_eval do
|
|
24
27
|
raise
|
25
28
|
end
|
26
29
|
|
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
30
|
private
|
80
31
|
|
81
32
|
def get_binding(values = nil)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mislav-hanna
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Mislav Marohni\xC4\x87"
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-05-
|
12
|
+
date: 2008-05-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: 2.
|
22
|
+
version: 2.1.0
|
23
23
|
version:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: haml
|
@@ -44,6 +44,7 @@ files:
|
|
44
44
|
- bin
|
45
45
|
- bin/hanna
|
46
46
|
- lib
|
47
|
+
- lib/hanna.rb
|
47
48
|
- lib/hanna
|
48
49
|
- lib/hanna/hanna.rb
|
49
50
|
- lib/hanna/rdoc_patch.rb
|
@@ -57,6 +58,7 @@ files:
|
|
57
58
|
- lib/hanna/template_files/page.haml
|
58
59
|
- lib/hanna/template_files/sections.haml
|
59
60
|
- lib/hanna/template_files/styles.sass
|
61
|
+
- lib/hanna/template_helpers.rb
|
60
62
|
- lib/hanna/template_page_patch.rb
|
61
63
|
has_rdoc: false
|
62
64
|
homepage: http://github.com/mislav/hanna
|
@@ -80,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
82
|
requirements: []
|
81
83
|
|
82
84
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.0
|
85
|
+
rubygems_version: 1.2.0
|
84
86
|
signing_key:
|
85
87
|
specification_version: 2
|
86
88
|
summary: An RDoc template that rocks
|