ddollar-hanna 0.1.4
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/Manifest +20 -0
- data/README.markdown +106 -0
- data/Rakefile +24 -0
- data/bin/hanna +75 -0
- data/hanna.gemspec +44 -0
- data/lib/hanna.rb +1 -0
- data/lib/hanna/hanna.rb +48 -0
- data/lib/hanna/rdoc_version.rb +21 -0
- data/lib/hanna/rdoctask.rb +41 -0
- data/lib/hanna/template_files/class_index.haml +3 -0
- data/lib/hanna/template_files/file_index.haml +25 -0
- data/lib/hanna/template_files/index.haml +11 -0
- data/lib/hanna/template_files/layout.haml +38 -0
- data/lib/hanna/template_files/method_list.haml +34 -0
- data/lib/hanna/template_files/method_search.js +55 -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 +97 -0
- data/lib/hanna/template_files/styles.sass +359 -0
- data/lib/hanna/template_helpers.rb +108 -0
- data/lib/hanna/template_page_patch.rb +38 -0
- metadata +130 -0
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
end
|
|
108
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'hanna/template_helpers'
|
|
2
|
+
|
|
3
|
+
RDoc::TemplatePage.class_eval do
|
|
4
|
+
|
|
5
|
+
include Hanna::TemplateHelpers
|
|
6
|
+
|
|
7
|
+
# overwrite the original method
|
|
8
|
+
alias :old_write_html_on :write_html_on # suppresses the overwrite warning
|
|
9
|
+
def write_html_on(io, values)
|
|
10
|
+
result = @templates.reverse.inject(nil) do |previous, template|
|
|
11
|
+
case template
|
|
12
|
+
when Haml::Engine
|
|
13
|
+
silence_warnings do
|
|
14
|
+
template.to_html(get_binding, :values => values) { previous }
|
|
15
|
+
end
|
|
16
|
+
when Sass::Engine
|
|
17
|
+
silence_warnings { template.to_css }
|
|
18
|
+
when String
|
|
19
|
+
ERB.new(template).result(get_binding(values){ previous })
|
|
20
|
+
when nil
|
|
21
|
+
previous
|
|
22
|
+
else
|
|
23
|
+
raise "don't know how to handle a template of class '#{template.class.name}'"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
io.write result
|
|
28
|
+
rescue
|
|
29
|
+
$stderr.puts "error while writing to #{io.inspect}"
|
|
30
|
+
raise
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def get_binding(values = nil)
|
|
36
|
+
binding
|
|
37
|
+
end
|
|
38
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ddollar-hanna
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.4
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- "Mislav Marohni\xC4\x87"
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
|
|
12
|
+
date: 2008-11-18 00:00:00 -08:00
|
|
13
|
+
default_executable: hanna
|
|
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.2.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: "2.0"
|
|
32
|
+
version:
|
|
33
|
+
- !ruby/object:Gem::Dependency
|
|
34
|
+
name: rake
|
|
35
|
+
version_requirement:
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ~>
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 0.8.2
|
|
41
|
+
version:
|
|
42
|
+
- !ruby/object:Gem::Dependency
|
|
43
|
+
name: echoe
|
|
44
|
+
version_requirement:
|
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: "0"
|
|
50
|
+
version:
|
|
51
|
+
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.
|
|
52
|
+
email: mislav.marohnic@gmail.com
|
|
53
|
+
executables:
|
|
54
|
+
- hanna
|
|
55
|
+
extensions: []
|
|
56
|
+
|
|
57
|
+
extra_rdoc_files:
|
|
58
|
+
- bin/hanna
|
|
59
|
+
- lib/hanna/hanna.rb
|
|
60
|
+
- lib/hanna/rdoc_version.rb
|
|
61
|
+
- lib/hanna/rdoctask.rb
|
|
62
|
+
- lib/hanna/template_files/class_index.haml
|
|
63
|
+
- lib/hanna/template_files/file_index.haml
|
|
64
|
+
- lib/hanna/template_files/index.haml
|
|
65
|
+
- lib/hanna/template_files/layout.haml
|
|
66
|
+
- lib/hanna/template_files/method_list.haml
|
|
67
|
+
- lib/hanna/template_files/method_search.js
|
|
68
|
+
- lib/hanna/template_files/page.haml
|
|
69
|
+
- lib/hanna/template_files/prototype-1.6.0.3.js
|
|
70
|
+
- lib/hanna/template_files/sections.haml
|
|
71
|
+
- lib/hanna/template_files/styles.sass
|
|
72
|
+
- lib/hanna/template_helpers.rb
|
|
73
|
+
- lib/hanna/template_page_patch.rb
|
|
74
|
+
- lib/hanna.rb
|
|
75
|
+
- README.markdown
|
|
76
|
+
files:
|
|
77
|
+
- bin/hanna
|
|
78
|
+
- lib/hanna/hanna.rb
|
|
79
|
+
- lib/hanna/rdoc_version.rb
|
|
80
|
+
- lib/hanna/rdoctask.rb
|
|
81
|
+
- lib/hanna/template_files/class_index.haml
|
|
82
|
+
- lib/hanna/template_files/file_index.haml
|
|
83
|
+
- lib/hanna/template_files/index.haml
|
|
84
|
+
- lib/hanna/template_files/layout.haml
|
|
85
|
+
- lib/hanna/template_files/method_list.haml
|
|
86
|
+
- lib/hanna/template_files/method_search.js
|
|
87
|
+
- lib/hanna/template_files/page.haml
|
|
88
|
+
- lib/hanna/template_files/prototype-1.6.0.3.js
|
|
89
|
+
- lib/hanna/template_files/sections.haml
|
|
90
|
+
- lib/hanna/template_files/styles.sass
|
|
91
|
+
- lib/hanna/template_helpers.rb
|
|
92
|
+
- lib/hanna/template_page_patch.rb
|
|
93
|
+
- lib/hanna.rb
|
|
94
|
+
- Rakefile
|
|
95
|
+
- README.markdown
|
|
96
|
+
- Manifest
|
|
97
|
+
- hanna.gemspec
|
|
98
|
+
has_rdoc: false
|
|
99
|
+
homepage: http://github.com/mislav/hanna
|
|
100
|
+
post_install_message:
|
|
101
|
+
rdoc_options:
|
|
102
|
+
- --line-numbers
|
|
103
|
+
- --inline-source
|
|
104
|
+
- --title
|
|
105
|
+
- Hanna
|
|
106
|
+
- --main
|
|
107
|
+
- README.markdown
|
|
108
|
+
require_paths:
|
|
109
|
+
- lib
|
|
110
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
|
+
requirements:
|
|
112
|
+
- - ">="
|
|
113
|
+
- !ruby/object:Gem::Version
|
|
114
|
+
version: "0"
|
|
115
|
+
version:
|
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
|
+
requirements:
|
|
118
|
+
- - ">="
|
|
119
|
+
- !ruby/object:Gem::Version
|
|
120
|
+
version: "1.2"
|
|
121
|
+
version:
|
|
122
|
+
requirements: []
|
|
123
|
+
|
|
124
|
+
rubyforge_project: hanna
|
|
125
|
+
rubygems_version: 1.2.0
|
|
126
|
+
signing_key:
|
|
127
|
+
specification_version: 2
|
|
128
|
+
summary: An RDoc template that rocks
|
|
129
|
+
test_files: []
|
|
130
|
+
|