Permalink
Browse files

Added a new section to the default module template which generates in…

…herited attribute documentation. Modified the rspec test for the module template to reflect the change.
  • Loading branch information...
Michael Smit
Michael Smit committed Apr 6, 2011
1 parent 0cf07ec commit 3873dcf7fb40839c8c4e1412d6dec2f3ff0af113
@@ -29,3 +29,5 @@ subgraph cluster_A_Z {
}
A -> B [style=dotted arrowType=none];
A -> BaseMod [style=dotted arrowType=none];
@@ -1,4 +1,5 @@
<h1>Module: A
<h1>Module: A
</h1>
@@ -10,7 +11,7 @@ <h1>Module: A
<dt class="r1">Includes:</dt>
<dd class="r1">B</dd>
<dd class="r1">B, BaseMod</dd>
@@ -87,6 +88,10 @@ <h2>Constant Summary</h2>
<h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
<ul class="summary">
@@ -106,6 +111,7 @@ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collap
<span class="summary_desc"><div class='inline'>Returns the value of attribute attr1.</div></span>
@@ -129,6 +135,7 @@ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collap
<span class="summary_desc"><div class='inline'>Returns the value of attribute attr2.</div></span>
@@ -152,6 +159,7 @@ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collap
<span class="summary_desc"><div class='inline'></div></span>
@@ -175,6 +183,7 @@ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collap
<span class="summary_desc"><div class='inline'>Sets the attribute attr4.</div></span>
@@ -185,8 +194,24 @@ <h2>Instance Attribute Summary <small>(<a href="#" class="summary_toggle">collap
</ul>
<h3 class="inherited">Attributes included from BaseMod</h3>
<p class="inherited">base_attr1, base_attr2, base_attr3</p>
<h2>Class Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
<h2>
Class Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
@@ -203,6 +228,7 @@ <h2>Class Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>
<span class="summary_desc"><div class='inline'></div></span>
@@ -212,7 +238,10 @@ <h2>Class Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>
</ul>
<h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
<h2>
Instance Method Summary
<small>(<a href="#" class="summary_toggle">collapse</a>)</small>
</h2>
<ul class="summary">
@@ -231,6 +260,7 @@ <h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse<
<span class="summary_desc"><div class='inline'></div></span>
@@ -251,6 +281,7 @@ <h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse<
<span class="summary_desc"><div class='inline'></div></span>
@@ -271,6 +302,7 @@ <h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse<
<span class="summary_desc"><div class='inline'>hello2.</div></span>
@@ -291,6 +323,7 @@ <h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse<
<span class="summary_desc"><div class='inline'></div></span>
@@ -312,6 +345,11 @@ <h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse<
<h3 class="inherited">Methods included from B</h3>
<p class="inherited">#c, #d</p>
<div id="instance_attr_details" class="attr_details">
<h2>Instance Attribute Details</h2>
@@ -339,12 +377,12 @@ <h2>Instance Attribute Details</h2>
<pre class="lines">
10
11
12</pre>
17
18
19</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 10</span>
<pre class="code"><span class="info file"># File '(stdin)', line 17</span>
def attr1
@attr1
@@ -378,12 +416,12 @@ <h2>Instance Attribute Details</h2>
<pre class="lines">
11
12
13</pre>
18
19
20</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 11</span>
<pre class="code"><span class="info file"># File '(stdin)', line 18</span>
def attr2
@attr2
@@ -488,12 +526,12 @@ <h3>Parameters:</h3>
<pre class="lines">
18
19
20</pre>
25
26
27</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 18</span>
<pre class="code"><span class="info file"># File '(stdin)', line 25</span>
def attr3
@attr3
@@ -545,12 +583,12 @@ <h3>Parameters:</h3>
<pre class="lines">
20
21
22</pre>
27
28
29</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 20</span>
<pre class="code"><span class="info file"># File '(stdin)', line 27</span>
def attr4=(value)
@attr4 = value
@@ -580,10 +618,10 @@ <h2>Class Method Details</h2>
<pre class="lines">
22</pre>
29</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 22</span>
<pre class="code"><span class="info file"># File '(stdin)', line 29</span>
def self.a; end</pre>
</td>
@@ -614,10 +652,10 @@ <h2>Instance Method Details</h2>
<pre class="lines">
23</pre>
30</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 23</span>
<pre class="code"><span class="info file"># File '(stdin)', line 30</span>
def a; end</pre>
</td>
@@ -650,10 +688,10 @@ <h2>Instance Method Details</h2>
<pre class="lines">
33</pre>
40</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 33</span>
<pre class="code"><span class="info file"># File '(stdin)', line 40</span>
def test_multi_overload(*args) end</pre>
</td>
@@ -710,10 +748,10 @@ <h3>Parameters:</h3>
<pre class="lines">
29</pre>
36</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 29</span>
<pre class="code"><span class="info file"># File '(stdin)', line 36</span>
def test_overload(*args) end</pre>
</td>
@@ -742,10 +780,10 @@ <h3>Parameters:</h3>
<pre class="lines">
36</pre>
43</pre>
</td>
<td>
<pre class="code"><span class="info file"># File '(stdin)', line 36</span>
<pre class="code"><span class="info file"># File '(stdin)', line 43</span>
def void_meth; end</pre>
</td>
@@ -16,7 +16,7 @@ Defined Under Namespace:
Includes:
---------
A::B::C, F, E, D, B
A::B::C, F, E, D, B, BaseMod
Class methods:
@@ -11,8 +11,15 @@ def d; end
def e; end
end
module BaseMod
attr_reader :base_attr1
attr_writer :base_attr2
attr_accessor :base_attr3
end
# Comments
module A
include BaseMod
attr_accessor :attr1
attr_reader :attr2
@@ -0,0 +1,17 @@
<% found_method = false %>
<% object.inheritance_tree(true)[1..-1].each do |superclass| %>
<% next if superclass.is_a?(YARD::CodeObjects::Proxy) %>
<% attribs = superclass.attributes[:instance] %>
<% next if attribs.size == 0 %>
<% if attr_listing.size == 0 && !found_method %><h2>Instance Attribute Summary</h2><% end %>
<% found_method = true %>
<h3 class="inherited">Attributes <%= superclass.type == :class ? 'inherited' : 'included' %> from <%= linkify superclass %></h3>
<p class="inherited"><%=
attribs.collect do |args|
name, methods = args
method = methods[:read] || methods[:write]
name = method.name.to_s.gsub(/^#/,'') if superclass.type == :module && object.class_mixins.include?(superclass)
linkify(method, name)
end.join(", ")
%></p>
<% end %>
@@ -3,7 +3,7 @@
def init
sections :header, :box_info, :pre_docstring, T('docstring'), :children,
:constant_summary, [T('docstring')], :inherited_constants,
:attribute_summary, [:item_summary],
:attribute_summary, [:item_summary], :inherited_attributes,
:method_summary, [:item_summary], :inherited_methods,
:methodmissing, [T('method_details')],
:attribute_details, [T('method_details')],

0 comments on commit 3873dcf

Please sign in to comment.