hanna-nouveau 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -2
- data/VERSION +1 -1
- data/lib/hanna-nouveau/template_files/class_index.erb +4 -0
- data/lib/hanna-nouveau/template_files/file_index.erb +9 -0
- data/lib/hanna-nouveau/template_files/index.erb +15 -0
- data/lib/hanna-nouveau/template_files/layout.erb +34 -0
- data/lib/hanna-nouveau/template_files/method_index.erb +11 -0
- data/lib/hanna-nouveau/template_files/method_list.erb +58 -0
- data/lib/hanna-nouveau/template_files/method_search.js +41 -59
- data/lib/hanna-nouveau/template_files/page.erb +48 -0
- data/lib/hanna-nouveau/template_files/sections.erb +92 -0
- data/lib/hanna-nouveau/template_files/styles.css +4 -0
- data/lib/hanna-nouveau.rb +46 -45
- metadata +13 -31
- data/lib/hanna-nouveau/template_files/class_index.haml +0 -3
- data/lib/hanna-nouveau/template_files/file_index.haml +0 -12
- data/lib/hanna-nouveau/template_files/index.haml +0 -11
- data/lib/hanna-nouveau/template_files/layout.haml +0 -34
- data/lib/hanna-nouveau/template_files/method_index.haml +0 -13
- data/lib/hanna-nouveau/template_files/method_list.haml +0 -56
- data/lib/hanna-nouveau/template_files/page.haml +0 -48
- data/lib/hanna-nouveau/template_files/prototype-1.6.0.3.js +0 -4320
- data/lib/hanna-nouveau/template_files/sections.haml +0 -88
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b034a18db202c97ad31b676e96922ad039ae319fba935e0f3d8d94fe4e20f453
|
4
|
+
data.tar.gz: 3249c6b9b4a593b4d1b57ed4314868bb2ed6004fd8bf106129dd5f004c5d3705
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813b0b2c4e7f467d8db20641fd1976eea53f52b0a9d138a3b5a3817af451b591d579cafac703fbde94abcb001a9a17265754b3b99734e4beae7b640f1cad2943
|
7
|
+
data.tar.gz: ecf57c820b6f19bae2b476796cbc5e1cb4de29fe8c38b3f08682ccf43decfafba0c833282624e020d8ee68a2d11e356a34ff1b0e402d31aa04edc4f580f365e2
|
data/README.rdoc
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
|
3
3
|
Based on the original Hanna by Mislav.
|
4
4
|
|
5
|
-
Hanna-nouveau is an RDoc generator
|
6
|
-
making the sources clean and readable. It's built with simplicity, beauty
|
5
|
+
Hanna-nouveau is an RDoc generator built with simplicity, beauty
|
7
6
|
and ease of browsing in mind.
|
8
7
|
|
9
8
|
Hanna-nouveau is distributed as a ruby gem:
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<h1>File Index</h1><% any_hidden = false %>
|
2
|
+
<ol class='files' id='index-entries'>
|
3
|
+
<% values[:files].each do |file|
|
4
|
+
hide = file.name =~ /\.rb$/
|
5
|
+
any_hidden = true if hide %><li<%= " class='other'" if hide %>><%= link_to(file.name, file.path) %></li>
|
6
|
+
<% end %><% if any_hidden %><li>
|
7
|
+
<a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
|
8
|
+
</li><% end %>
|
9
|
+
</ol>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
|
2
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
3
|
+
<head>
|
4
|
+
<title><%=h @options.title %></title>
|
5
|
+
<meta content='text/html; charset=<%=h @options.charset %>' http-equiv='Content-Type'>
|
6
|
+
</head>
|
7
|
+
<frameset border='1' bordercolor='gray' cols='20%, *' frameborder='1'>
|
8
|
+
<frameset rows='15%, 35%, 50%'>
|
9
|
+
<frame name='Files' src='fr_file_index.html' title='Files'>
|
10
|
+
<frame name='Classes' src='fr_class_index.html'>
|
11
|
+
<frame name='Methods' src='fr_method_index.html'>
|
12
|
+
</frameset>
|
13
|
+
<frame name='docwin' src='<%=h @main_page_uri %>'></frame>
|
14
|
+
</frameset>
|
15
|
+
</html>
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><% values = values[:values]; index = values[:list_title] %>
|
2
|
+
<html lang='en'>
|
3
|
+
<head>
|
4
|
+
<title><%= h(values[:title]) if values[:title] %></title>
|
5
|
+
<meta content='text/html; charset=<%=h @options.charset %>' http-equiv='Content-Type'>
|
6
|
+
<link href='<%=h values[:stylesheet] %>' media='screen' rel='stylesheet' type='text/css'>
|
7
|
+
<% if index %><base target='docwin'>
|
8
|
+
<% else %><script type='text/javascript'>
|
9
|
+
function popupCode(url) {
|
10
|
+
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
11
|
+
}
|
12
|
+
|
13
|
+
function toggleCode(id) {
|
14
|
+
var code = document.getElementById(id)
|
15
|
+
|
16
|
+
code.style.display = code.style.display != 'block' ? 'block' : 'none'
|
17
|
+
return true
|
18
|
+
}
|
19
|
+
|
20
|
+
// Make codeblocks hidden by default
|
21
|
+
document.writeln('<' + 'style type="text/css">.method .source pre { display: none }<\/style>')
|
22
|
+
</script>
|
23
|
+
<% end %></head>
|
24
|
+
<body class='<%= index ? 'list' : 'page' %>'>
|
25
|
+
<% if index %><div id='index'><%= yield %></div>
|
26
|
+
<% else %><div class='<%= values[:classmod] ? 'class' : 'file' %>' id='wrapper'>
|
27
|
+
<%= yield %>
|
28
|
+
<div id='footer-push'></div>
|
29
|
+
</div>
|
30
|
+
<div id='footer'>
|
31
|
+
<a href="https://github.com/jeremyevans/hanna-nouveau"><strong>Hanna Nouveau</strong> RDoc template</a>
|
32
|
+
</div>
|
33
|
+
<% end %></body>
|
34
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<h1><%=h values[:list_title] %></h1>
|
2
|
+
<form id='search_form'>
|
3
|
+
<input autocomplete='off' class='untouched' id='search' placeholder='Enter search terms...' type='text'>
|
4
|
+
<span class='clear_button' id='clear_button'>
|
5
|
+
x
|
6
|
+
</span>
|
7
|
+
</form>
|
8
|
+
<ol class='methods' id='index-entries'>
|
9
|
+
<% (values[:attributes] + values[:methods]).uniq.each do |entry| %><li><%= link_to_method(entry, [classfile(entry.parent), entry.aref].join('#')) %></li>
|
10
|
+
<% end %></ol>
|
11
|
+
<script src='method_search.js' type='text/javascript'></script>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<%
|
2
|
+
values = values[:values] if values[:values]
|
3
|
+
entry = values[:entry]
|
4
|
+
sections = values[:sections].keys if values.has_key?(:sections)
|
5
|
+
methods = entry.method_list + entry.attributes
|
6
|
+
unless methods.empty? %><div id='method-list'>
|
7
|
+
<h2>Methods</h2>
|
8
|
+
<% %w[attr attr_accessor attr_reader attr_writer class instance].each do |type|
|
9
|
+
(RDoc::VISIBILITIES rescue RDoc::Context::VISIBILITIES).each do |vis|
|
10
|
+
list = methods.reject { |x| x.respond_to?(:is_alias_for) && x.is_alias_for }.select { |x| x.visibility == vis && x.type == type.to_s }.sort
|
11
|
+
next if list.empty?
|
12
|
+
type_result = ""
|
13
|
+
if type =~ /^attr_/
|
14
|
+
type_result += type.sub(/^attr_/, '').capitalize
|
15
|
+
else
|
16
|
+
type_result += type.capitalize
|
17
|
+
end
|
18
|
+
type_result = "#{vis.to_s.capitalize} #{type_result}"
|
19
|
+
%><h3><%=h type_result %></h3>
|
20
|
+
<ol>
|
21
|
+
<%
|
22
|
+
list.each do |method|
|
23
|
+
if method.respond_to?(:aref)
|
24
|
+
if method.name.to_s.empty? && method.call_seq %><li><%= link_to(method.call_seq.gsub(/<br\s*\/?>/, "").split(/[\r\n]+/).map{ |s| s.split(/([({]+|\[\{|\s+(#?=>|→)\s+)/).first.sub(/^[A-Za-z0-9_:]+\./, "").sub(/\s+=\s+.*/, "=").strip }.uniq.join("<br />\n"), '#' + method.aref) %></li>
|
25
|
+
<% else %><li><%= link_to(method.name, '#' + method.aref) %></li>
|
26
|
+
<% end
|
27
|
+
elsif method.respond_to?(:html_name) %><li><%= link_to(method.name, "#method-#{method.html_name}") %></li>
|
28
|
+
<% else %><li><%=h method.name %></li>
|
29
|
+
<% end
|
30
|
+
end %></ol>
|
31
|
+
<% end
|
32
|
+
end %></div>
|
33
|
+
<%
|
34
|
+
end
|
35
|
+
if entry.requires or sections or entry.includes %><div id='context'>
|
36
|
+
<% unless entry.requires.empty? %><div id='requires'>
|
37
|
+
<h2>Required files</h2>
|
38
|
+
<ol>
|
39
|
+
<% entry.requires.each do |req| %><li><%=h req.name %></li>
|
40
|
+
<% end %></ol>
|
41
|
+
</div>
|
42
|
+
<% end
|
43
|
+
if sections && (sections.length > 1 || sections.first.title.to_s != '')
|
44
|
+
%><div id='contents'>
|
45
|
+
<h2>Contents</h2>
|
46
|
+
<ol>
|
47
|
+
<% sections.sort_by{|s| s.title.to_s}.each do |section| %><li><%= link_to(section.title, "##{section.aref}") %></li>
|
48
|
+
<% end %></ol>
|
49
|
+
</div>
|
50
|
+
<% end
|
51
|
+
unless entry.includes.empty?
|
52
|
+
%><div id='includes'>
|
53
|
+
<h2>Included modules</h2>
|
54
|
+
<ol>
|
55
|
+
<% entry.includes.each do |inc| %><li><%= (mod = inc.module).is_a?(String) ? h(inc.name) : link_to(inc.name, entry.aref_to(mod.path)) %></li>
|
56
|
+
<% end %></ol>
|
57
|
+
</div>
|
58
|
+
<% end %></div><% end %>
|
@@ -1,63 +1,45 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
performSearch();
|
5
|
-
});
|
6
|
-
|
7
|
-
// Remove the default search box value when the user puts the focus on
|
8
|
-
// the search box for the first time.
|
9
|
-
var search_box = $('search');
|
10
|
-
if ($F('search') == 'Enter search terms...') {
|
11
|
-
search_box.observe('focus', function() {
|
12
|
-
if (search_box.hasClassName('untouched')) {
|
13
|
-
search_box.removeClassName('untouched');
|
14
|
-
search_box.value = '';
|
15
|
-
}
|
16
|
-
});
|
17
|
-
} else {
|
18
|
-
search_box.removeClassName('untouched');
|
19
|
-
}
|
20
|
-
|
21
|
-
search_box.insert({
|
22
|
-
after: new Element('span', { 'class': 'clear_button' }).update('x').observe('click', function(e) {
|
23
|
-
e.stopPropagation()
|
24
|
-
search_box.setValue('')
|
25
|
-
search_box.focus()
|
26
|
-
})
|
27
|
-
})
|
28
|
-
});
|
29
|
-
|
30
|
-
function searchInIndex(query) {
|
31
|
-
var i;
|
32
|
-
var results = [];
|
33
|
-
query = query.toLowerCase();
|
34
|
-
for (i = 0; i < search_index.length; i++) {
|
35
|
-
if (search_index[i].method.indexOf(query) != -1) {
|
36
|
-
results.push(search_index[i]);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
return results;
|
40
|
-
}
|
1
|
+
var search_box = document.getElementById('search');
|
2
|
+
var search_timeout;
|
3
|
+
var search_value = search_box.value;
|
41
4
|
|
42
|
-
function
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
5
|
+
function performSearch(e) {
|
6
|
+
if (e) {
|
7
|
+
e.preventDefault();
|
8
|
+
}
|
9
|
+
if (search.value === search_value) {
|
10
|
+
return;
|
11
|
+
}
|
12
|
+
search_value = search_box.value;
|
50
13
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
$('search-results').hide();
|
14
|
+
if (search_value == '') {
|
15
|
+
document.querySelectorAll("#index-entries li.hide").forEach(elem => {
|
16
|
+
elem.classList.remove('hide');
|
17
|
+
});
|
56
18
|
} else {
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
19
|
+
document.querySelectorAll("#index-entries span.method_name").forEach(elem => {
|
20
|
+
var value = elem.getAttribute('value');
|
21
|
+
var li_classes = elem.parentElement.parentElement.classList;
|
22
|
+
if (value && value.includes(search_value)) {
|
23
|
+
li_classes.remove('hide');
|
24
|
+
} else {
|
25
|
+
li_classes.add('hide');
|
26
|
+
}
|
27
|
+
});
|
28
|
+
}
|
63
29
|
}
|
30
|
+
|
31
|
+
document.getElementById('search_form').onsubmit = performSearch;
|
32
|
+
|
33
|
+
search.oninput = function(e) {
|
34
|
+
if (search_timeout) {
|
35
|
+
clearTimeout(search_timeout);
|
36
|
+
}
|
37
|
+
search_timeout = setTimeout(performSearch, 300);
|
38
|
+
};
|
39
|
+
|
40
|
+
document.getElementById('clear_button').onclick = function(e) {
|
41
|
+
e.stopPropagation();
|
42
|
+
search_box.value = '';
|
43
|
+
performSearch();
|
44
|
+
search_box.focus();
|
45
|
+
};
|
@@ -0,0 +1,48 @@
|
|
1
|
+
<%
|
2
|
+
values = values[:values] if values[:values]
|
3
|
+
file_page = !values[:classmod]
|
4
|
+
title_in_description = values[:entry].description && values[:entry].description =~ /^\s*<h1>/m
|
5
|
+
%><div class='header'>
|
6
|
+
<%
|
7
|
+
title = if file_page
|
8
|
+
h(values[:file].name)
|
9
|
+
else
|
10
|
+
"<span class='type'>#{values[:classmod]}</span>\n#{h values[:entry].full_name}"
|
11
|
+
end
|
12
|
+
|
13
|
+
if title_in_description %><div class='name'><%= title %></div>
|
14
|
+
<% else %><h1 class='name'><%= title %>
|
15
|
+
</h1>
|
16
|
+
<% end
|
17
|
+
|
18
|
+
if file_page %><div class='paths'>
|
19
|
+
<%=h values[:file].relative_name %>
|
20
|
+
</div>
|
21
|
+
<% else %><ol class='paths'>
|
22
|
+
<% values[:entry].in_files.each_with_index do |file, index| %><li<%= " class='other'" if index > 0 %>>
|
23
|
+
<%= link_to(file.full_name, Pathname.new(file.path).relative_path_from(Pathname.new(values[:entry].path).dirname)) %>
|
24
|
+
</li>
|
25
|
+
<% end
|
26
|
+
if values[:entry].in_files.size > 1 %><li>
|
27
|
+
<a class='show' href='#' onclick='this.parentNode.parentNode.className += " expanded"; this.parentNode.removeChild(this); return false'>show all</a>
|
28
|
+
</li>
|
29
|
+
<% end %></ol>
|
30
|
+
<% end
|
31
|
+
|
32
|
+
if !file_page && values[:entry].type == "class" %><div class='parent'>
|
33
|
+
Superclass:
|
34
|
+
<strong><%= (values[:entry].superclass.kind_of?(String) || !values[:entry].superclass) ? h(values[:entry].superclass) : link_to(values[:entry].superclass.name, Pathname.new(class_dir) + Pathname.new(values[:entry].superclass.path).relative_path_from(Pathname.new values[:entry].path)) %></strong>
|
35
|
+
</div>
|
36
|
+
<% end
|
37
|
+
|
38
|
+
if values[:entry].respond_to?(:last_modified) and values[:entry].last_modified %><div class='last-update'>
|
39
|
+
Last Update:
|
40
|
+
<span class='datetime'><%=h values[:entry].last_modified %></span>
|
41
|
+
</div>
|
42
|
+
<% end %></div>
|
43
|
+
<div id='content'>
|
44
|
+
<div id='text'>
|
45
|
+
<% if values[:description] %><div id='description'><%= sanitize_code_blocks(frame_link(values[:description])) %></div>
|
46
|
+
<% end %><%= frame_link(block.call) %>
|
47
|
+
</div>
|
48
|
+
</div>
|
@@ -0,0 +1,92 @@
|
|
1
|
+
<%
|
2
|
+
values = values[:values] if values[:values]
|
3
|
+
unless values[:entry].classes_and_modules.empty? %><div id='class-list'>
|
4
|
+
<h2>Classes and Modules</h2>
|
5
|
+
<ol>
|
6
|
+
<% (values[:entry].modules.sort + values[:entry].classes.sort).each do |mod| %><li><%= link_to(mod.full_name, values[:entry].aref_to(mod.path)) %></li>
|
7
|
+
<% end %></ol>
|
8
|
+
</div>
|
9
|
+
<% end
|
10
|
+
|
11
|
+
values[:sections].sort_by{|s, h| s.title.to_s}.each do |section, h|
|
12
|
+
constants, attributes, alias_types, method_types = h.values_at(:constants, :attributes, :alias_types, :method_types)
|
13
|
+
%><div id='section'>
|
14
|
+
<% if section.title.to_s != '' %><h2>
|
15
|
+
<a name='<%=h section.aref %>'><%=h section.title %></a>
|
16
|
+
<% if section.comment %><div class='section-comment'><%= section.description %></div>
|
17
|
+
<% end %></h2>
|
18
|
+
<% end
|
19
|
+
unless constants.empty? %><div id='constants-list'>
|
20
|
+
<h2>Constants</h2>
|
21
|
+
<div class='name-list'>
|
22
|
+
<table summary='Constants'>
|
23
|
+
<% constants.each do |const| %><tr class='top-aligned-row context-row'>
|
24
|
+
<td class='context-item-name'><%= const.name %></td>
|
25
|
+
<td>=</td>
|
26
|
+
<td class='context-item-value'><%= const.value %></td>
|
27
|
+
<% if const.description %><td> </td>
|
28
|
+
<td class='context-item-desc'><%= const.description %></td>
|
29
|
+
<% end %></tr>
|
30
|
+
<% end %></table>
|
31
|
+
</div>
|
32
|
+
</div>
|
33
|
+
<% end
|
34
|
+
unless alias_types.empty?
|
35
|
+
alias_types.each do |type, aliases|
|
36
|
+
%><div id='aliases-list'>
|
37
|
+
<h2><%= type %> Aliases</h2>
|
38
|
+
<div class='name-list'>
|
39
|
+
<table summary='<%= type %> Aliases'>
|
40
|
+
<% aliases.each do |alia| %><tr class='top-aligned-row context-row'>
|
41
|
+
<td class='context-item-name'><%= alia.name %></td>
|
42
|
+
<td>-></td>
|
43
|
+
<td class='context-item-value'><%= link_to(alia.is_alias_for.name, "##{alia.is_alias_for.aref}") %></td>
|
44
|
+
<% unless alia.description.empty? %><td class='context-item-desc'><%= alia.description %></td>
|
45
|
+
<% end %></tr>
|
46
|
+
<% end %></table>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<% end
|
50
|
+
end
|
51
|
+
unless attributes.empty? %><div id='attribute-list'>
|
52
|
+
<h2 class='section-bar'>Attributes</h2>
|
53
|
+
<div class='name-list'>
|
54
|
+
<table>
|
55
|
+
<% attributes.each do |attrib| %><tr class='top-aligned-row context-row'>
|
56
|
+
<td class='context-item-name'>
|
57
|
+
<a name='<%=h attrib.aref %>'><%= attrib.name %></a>
|
58
|
+
</td>
|
59
|
+
<td class='context-item-value'><%= attrib.rw ? "[#{attrib.rw}]" : ' ' %></td>
|
60
|
+
<td class='context-item-desc'><%= sanitize_code_blocks(attrib.description) %></td>
|
61
|
+
</tr>
|
62
|
+
<% end %></table>
|
63
|
+
</div>
|
64
|
+
</div>
|
65
|
+
<% end
|
66
|
+
unless method_types.empty? %><div id='methods'>
|
67
|
+
<% method_types.each do |type, list| next if list.empty? %><h2><%= type %> methods</h2>
|
68
|
+
<% list.each do |method| %><div class='method <%= "#{type.gsub(/\s+/, '-')}".downcase %>' id='method-<%= method.aref %>'>
|
69
|
+
<a name='<%= method.aref %>'></a>
|
70
|
+
<div class='synopsis'>
|
71
|
+
<% if method.call_seq %><span class='name'>
|
72
|
+
<% method.call_seq.split(/\r?\n/).each do |seq| %><div><%= seq %></div>
|
73
|
+
</span>
|
74
|
+
<% end
|
75
|
+
else %><span class='name'><%= method.name %></span><span class='arguments'><%= method.params %></span>
|
76
|
+
|
77
|
+
<% end %></div>
|
78
|
+
<% if method.description %><div class='description'>
|
79
|
+
<%= sanitize_code_blocks(method.description) %>
|
80
|
+
</div>
|
81
|
+
<% end
|
82
|
+
if method.markup_code
|
83
|
+
name = "#{method.aref}-source" %><div class='source'>
|
84
|
+
<a class='source-toggle' href='#' onclick='toggleCode('<%= name %>'); return false'>
|
85
|
+
[show source]
|
86
|
+
</a>
|
87
|
+
<pre id='<%= name %>'><%= method.markup_code %></pre>
|
88
|
+
</div>
|
89
|
+
<% end %></div>
|
90
|
+
<% end
|
91
|
+
end %></div>
|
92
|
+
<% end %></div><% end %>
|
@@ -128,6 +128,10 @@ table {
|
|
128
128
|
padding: 0.4em 0.5em; }
|
129
129
|
#index ol li {
|
130
130
|
white-space: nowrap; }
|
131
|
+
#index #index-entries li.hide {
|
132
|
+
display: none; }
|
133
|
+
#index #index-entries.all li.hide {
|
134
|
+
display: block; }
|
131
135
|
#index #index-entries li a {
|
132
136
|
padding: 1px 2px; }
|
133
137
|
#index #index-entries.classes {
|
data/lib/hanna-nouveau.rb
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
# Michael Granger <ged@FaerieMUD.org>, who had maintained the original RDoc template
|
13
13
|
|
14
14
|
require 'pathname'
|
15
|
-
require '
|
15
|
+
require 'erb'
|
16
16
|
require 'rdoc/rdoc' unless defined?(RDoc::Markup::ToHtml)
|
17
17
|
require 'rdoc/generator'
|
18
18
|
|
@@ -47,17 +47,17 @@ end
|
|
47
47
|
|
48
48
|
class RDoc::Generator::Hanna
|
49
49
|
STYLE = 'styles.css'
|
50
|
-
LAYOUT = 'layout.
|
50
|
+
LAYOUT = 'layout.erb'
|
51
51
|
|
52
|
-
INDEX_PAGE = 'index.
|
53
|
-
CLASS_PAGE = 'page.
|
54
|
-
METHOD_LIST_PAGE = 'method_list.
|
52
|
+
INDEX_PAGE = 'index.erb'
|
53
|
+
CLASS_PAGE = 'page.erb'
|
54
|
+
METHOD_LIST_PAGE = 'method_list.erb'
|
55
55
|
FILE_PAGE = CLASS_PAGE
|
56
|
-
SECTIONS_PAGE = 'sections.
|
56
|
+
SECTIONS_PAGE = 'sections.erb'
|
57
57
|
|
58
|
-
FILE_INDEX = 'file_index.
|
59
|
-
CLASS_INDEX = 'class_index.
|
60
|
-
METHOD_INDEX = 'method_index.
|
58
|
+
FILE_INDEX = 'file_index.erb'
|
59
|
+
CLASS_INDEX = 'class_index.erb'
|
60
|
+
METHOD_INDEX = 'method_index.erb'
|
61
61
|
|
62
62
|
CLASS_DIR = 'classes'
|
63
63
|
FILE_DIR = 'files'
|
@@ -68,7 +68,9 @@ class RDoc::Generator::Hanna
|
|
68
68
|
METHOD_INDEX_OUT = 'fr_method_index.html'
|
69
69
|
STYLE_OUT = File.join('css', 'style.css')
|
70
70
|
|
71
|
-
|
71
|
+
METHOD_SEARCH_JS = "method_search.js"
|
72
|
+
|
73
|
+
DESCRIPTION = 'RDoc generator designed with simplicity, beauty and ease of browsing in mind'
|
72
74
|
|
73
75
|
# EPIC CUT AND PASTE TIEM NAO -- GG
|
74
76
|
RDoc::RDoc.add_generator( self )
|
@@ -117,17 +119,19 @@ class RDoc::Generator::Hanna
|
|
117
119
|
FileUtils.mkdir css_dir
|
118
120
|
end
|
119
121
|
|
120
|
-
File.
|
122
|
+
File.binwrite(File.join(css_dir, 'style.css'), File.read(templjoin(STYLE)))
|
121
123
|
end
|
122
124
|
|
123
125
|
# FIXME refactor
|
124
126
|
def generate_indexes
|
125
127
|
@main_page_uri = @files.find { |f| f.name == @options.main_page }.path rescue ''
|
126
|
-
File.
|
128
|
+
File.binwrite(outjoin(INDEX_OUT), erb_template(templjoin(INDEX_PAGE)).to_html(binding))
|
127
129
|
|
128
130
|
generate_index(FILE_INDEX_OUT, FILE_INDEX, 'File', { :files => @files})
|
129
131
|
generate_index(CLASS_INDEX_OUT, CLASS_INDEX, 'Class', { :classes => @classes })
|
130
132
|
generate_index(METHOD_INDEX_OUT, METHOD_INDEX, 'Method', { :methods => @methods, :attributes => @attributes })
|
133
|
+
|
134
|
+
File.binwrite(outjoin(METHOD_SEARCH_JS), File.binread(templjoin(METHOD_SEARCH_JS)))
|
131
135
|
end
|
132
136
|
|
133
137
|
def generate_index(outfile, templfile, index_name, values)
|
@@ -136,18 +140,14 @@ class RDoc::Generator::Hanna
|
|
136
140
|
:list_title => "#{index_name} Index"
|
137
141
|
})
|
138
142
|
|
139
|
-
index =
|
143
|
+
index = erb_template(templjoin(templfile))
|
140
144
|
|
141
|
-
File.
|
142
|
-
f << with_layout(values) do
|
143
|
-
index.to_html(binding, values)
|
144
|
-
end
|
145
|
-
end
|
145
|
+
File.binwrite(outjoin(outfile), with_layout(values){index.to_html(binding, values)})
|
146
146
|
end
|
147
147
|
|
148
148
|
def generate_file_files
|
149
|
-
file_page =
|
150
|
-
method_list_page =
|
149
|
+
file_page = erb_template(templjoin(FILE_PAGE))
|
150
|
+
method_list_page = erb_template(templjoin(METHOD_LIST_PAGE))
|
151
151
|
|
152
152
|
# FIXME non-Ruby files
|
153
153
|
@files.each do |file|
|
@@ -176,14 +176,14 @@ class RDoc::Generator::Hanna
|
|
176
176
|
FileUtils.mkdir_p dir
|
177
177
|
end
|
178
178
|
|
179
|
-
File.
|
179
|
+
File.binwrite(outjoin(file.path), result)
|
180
180
|
end
|
181
181
|
end
|
182
182
|
|
183
183
|
def generate_class_files
|
184
|
-
class_page =
|
185
|
-
method_list_page =
|
186
|
-
sections_page =
|
184
|
+
class_page = erb_template(templjoin(CLASS_PAGE))
|
185
|
+
method_list_page = erb_template(templjoin(METHOD_LIST_PAGE))
|
186
|
+
sections_page = erb_template(templjoin(SECTIONS_PAGE))
|
187
187
|
# FIXME refactor
|
188
188
|
|
189
189
|
@classes.each do |klass|
|
@@ -227,12 +227,12 @@ class RDoc::Generator::Hanna
|
|
227
227
|
FileUtils.mkdir_p dir
|
228
228
|
end
|
229
229
|
|
230
|
-
File.
|
230
|
+
File.binwrite(outfile, result)
|
231
231
|
end
|
232
232
|
end
|
233
233
|
|
234
234
|
def with_layout(values)
|
235
|
-
layout =
|
235
|
+
layout = erb_template(templjoin(LAYOUT))
|
236
236
|
layout.to_html(binding, :values => values) { yield }
|
237
237
|
end
|
238
238
|
|
@@ -265,7 +265,7 @@ class RDoc::Generator::Hanna
|
|
265
265
|
end
|
266
266
|
|
267
267
|
def h(html)
|
268
|
-
CGI::escapeHTML(html)
|
268
|
+
CGI::escapeHTML(html.to_s)
|
269
269
|
end
|
270
270
|
|
271
271
|
# XXX may my sins be not visited upon my sons.
|
@@ -298,21 +298,6 @@ class RDoc::Generator::Hanna
|
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
301
|
-
def build_javascript_search_index(entries)
|
302
|
-
result = "var search_index = [\n"
|
303
|
-
entries.each do |entry|
|
304
|
-
method_name = entry.name
|
305
|
-
module_name = entry.parent_name
|
306
|
-
# FIXME link
|
307
|
-
html = link_to_method(entry, [classfile(entry.parent), (entry.aref rescue "method-#{entry.html_name}")].join('#'))
|
308
|
-
result << " { method: '#{method_name.downcase}', " +
|
309
|
-
"module: '#{module_name.downcase}', " +
|
310
|
-
"html: '#{html}' },\n"
|
311
|
-
end
|
312
|
-
result << "]"
|
313
|
-
result
|
314
|
-
end
|
315
|
-
|
316
301
|
def link_to(text, url = nil, classname = nil)
|
317
302
|
class_attr = classname ? ' class="%s"' % classname : ''
|
318
303
|
|
@@ -329,7 +314,7 @@ class RDoc::Generator::Hanna
|
|
329
314
|
def link_to_method(entry, url = nil, classname = nil)
|
330
315
|
method_name = entry.pretty_name rescue entry.name
|
331
316
|
module_name = entry.parent_name rescue entry.name
|
332
|
-
link_to %Q(<span class="method_name">#{h method_name}</span> <span class="module_name">(#{h module_name})</span>), url, classname
|
317
|
+
link_to %Q(<span class="method_name" value="#{entry.name}">#{h method_name}</span> <span class="module_name">(#{h module_name})</span>), url, classname
|
333
318
|
end
|
334
319
|
|
335
320
|
def classfile(klass)
|
@@ -345,7 +330,23 @@ class RDoc::Generator::Hanna
|
|
345
330
|
File.join(@templatedir, name)
|
346
331
|
end
|
347
332
|
|
348
|
-
|
349
|
-
|
333
|
+
class ERB < ::ERB
|
334
|
+
def to_html(binding, values = nil, &block)
|
335
|
+
local_values = {}
|
336
|
+
binding.local_variables.each do |lv|
|
337
|
+
local_values[lv] = binding.local_variable_get(lv)
|
338
|
+
end
|
339
|
+
binding.local_variable_set(:values, values) if values
|
340
|
+
binding.local_variable_set(:block, block) if block
|
341
|
+
html = result(binding)
|
342
|
+
local_values.each do |lv, val|
|
343
|
+
binding.local_variable_set(lv, val)
|
344
|
+
end
|
345
|
+
html
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
def erb_template(file)
|
350
|
+
ERB.new(File.read(file))
|
350
351
|
end
|
351
352
|
end
|