Skip to content

Commit

Permalink
adding methods and style
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Apr 12, 2010
1 parent 1a4f628 commit 7d11fbf
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/paddle.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
###
# Paddle is an RDoc template that will emit iPad compatible books!
module Paddle
# Test Attribute
attr_accessor :foo

VERSION = '1.0.0'
end
12 changes: 12 additions & 0 deletions lib/rdoc/generator/paddle.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ def emit_title

def emit_classfiles
@classes.each do |klass|
klass_methods = []
instance_methods = []

klass.method_list.each do |method|
next if 'private' == method.visibility.to_s
if method.type == 'class'
klass_methods << method
else
instance_methods << method
end
end

template = ERB.new File.read(File.join(TEMPLATE_DIR, 'classfile.html.erb')),
nil, '<>'

Expand Down
73 changes: 72 additions & 1 deletion lib/templates/classfile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
<title>
<%= klass.name %>
</title>
<style>
dt, dd {
margin: 0;
}
dt.name {
float: left;
}
dd.explanation {
clear: both;
margin-bottom: 0.5em;
margin-left: 1.5em;
}
</style>
</head>
<body>
<h1>
Expand Down Expand Up @@ -35,7 +48,65 @@
<% end %>
</h1>
<% if klass.description && !klass.description.empty? %>
<%= klass.description %>
<div id="description" class="alt">
<%= klass.description.strip.gsub(/<pre>\s*<\/pre>/, '') %>
</div>
<% end %>

<!-- Constants -->
<% unless klass.constants.empty? %>
<h3>Constants</h3>
<% klass.constants.sort_by { |x| x.name }.each do |const| %>
<dl>
<dt class="name">
<%= const.name %>
</dt>
<dd class="explanation"><%= const.description %></dd>
</dl>
<% end %>
<% end %>

<!-- Attributes -->
<% unless klass.attributes.empty? %>
<h3>Attributes</h3>
<% klass.attributes.sort_by { |x| x.name }.each do |attr| %>
<dl>
<dt class="name">
<%= attr.name %>
<span class="optional"><%= attr.rw %></span>
</dt>
<dd class="explanation"><%= attr.description.strip %></dd>
</dl>
<% end %>
<% end %>

<!-- Class Methods -->
<% unless klass_methods.empty? %>
<h3>Public Class Methods</h3>
<% klass_methods.each do |method| %>
<dl class="method">
<dt class="name">
<a name="<%= method.aref %>" ></a>
<%= method.name %><%= method.params %>
</dt>
<dd class="explanation"><%= method.description %></dd>
</dl>
<% end %>
<% end %>

<!-- Instance Methods -->
<% unless instance_methods.empty? %>
<h3>Public Instance Methods</h3>
<% instance_methods.each do |method| %>
<dl class="method">
<dt class="name">
<a name="<%= method.aref %>" ></a>
<%= method.name %><%= method.params %>
</dt>
<dd class="explanation"><%= method.description %></dd>
</dl>
<% end %>
<% end %>

</body>
</html>
2 changes: 1 addition & 1 deletion lib/templates/toc.ncx.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</navLabel>
<content src="doc/title.html"/>
</navPoint>
<% @classes.each_with_index do |klass, i| %>
<% @classes.sort_by { |x| x.full_name }.each_with_index do |klass, i| %>
<navPoint id="navPoint-<%= i + 3 %>" playOrder="<%= i + 3 %>">
<navLabel>
<text><%= klass.full_name %></text>
Expand Down

0 comments on commit 7d11fbf

Please sign in to comment.