Skip to content
Browse files

adding methods and style

  • Loading branch information...
1 parent 1a4f628 commit 7d11fbf70092c45f5913a7f26604c0f0da146812 @tenderlove committed Apr 12, 2010
Showing with 88 additions and 2 deletions.
  1. +3 −0 lib/paddle.rb
  2. +12 −0 lib/rdoc/generator/paddle.rb
  3. +72 −1 lib/templates/classfile.html.erb
  4. +1 −1 lib/templates/toc.ncx.erb
View
3 lib/paddle.rb
@@ -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
View
12 lib/rdoc/generator/paddle.rb
@@ -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, '<>'
View
73 lib/templates/classfile.html.erb
@@ -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>
@@ -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>
View
2 lib/templates/toc.ncx.erb
@@ -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>

0 comments on commit 7d11fbf

Please sign in to comment.
Something went wrong with that request. Please try again.