Alias for attribute causes aliasing method to appear in Attributes section
When defining an alias for an attribute in a class, the aliasing method is incorrectly displayed in the attributes section of the generated documentation.
For example, consider the following code in lib/foo.rb:
class Foo
attr :bar
alias baz bar
end
When running rdoc, the documentation for the Foo class shows:
This behavior is misleading, as baz is not a separate attribute but an alias method for bar method (and attribute). It would be beneficial to adjust the documentation generation to prevent alias methods from appearing in the attributes section.
Reproduced this behavior on v6.11.0.
@gemmaro Can you help me understand what you expect to see? It sounds like you want to completely omit mentioning the alias, but I think there's value in mentioning it as an alias, perhaps similar to how rdoc renders non-attribute methods:
WDYT?
@flavorjones I agree that having links between aliasing methods and aliased attributes is beneficial. Here's what I expect to see, based on the Darkfish theme (though it may vary in other themes):
- Aliasing method names should be listed under the instance methods section (e.g., "Public Instance Methods").
- Each aliasing method should have its own document comment.
- The description of the aliasing method should include a link to the aliased instance variable, labeled as "Alias for:".
- The aliased attribute should link back to the aliasing methods, indicated as "Also aliased as:".
- The left side menu should include the aliasing method under the "Methods" section.
For example, consider the following lib/foo.rb:
class Foo
# Some document comment about bar.
attr :bar
# Some document comment about baz.
alias baz bar
# Some document comment about qux.
def qux; end
# Some document comment about quux.
alias quux qux
end
Currently, RDoc generates:
What I expect to see is:
manually edited diff for op_dir/Foo.html
diff --git a/doc/Foo.html b/doc/Foo.html
index b521e85..c61b374 100644
--- a/doc/Foo.html
+++ b/doc/Foo.html
@@ -72,6 +72,7 @@
<h3>Methods</h3>
<ul class="link-list" role="directory">
+ <li ><a href="#method-i-baz">#baz</a>
<li ><a href="#method-i-quux">#quux</a>
<li ><a href="#method-i-qux">#qux</a>
</ul>
@@ -107,15 +108,9 @@
<div class="method-description">
<p>Some document comment about bar.</p>
</div>
- </div>
- <div id="attribute-i-baz" class="method-detail">
- <div class="method-heading attribute-method-heading">
- <span class="method-name">baz</span><span
- class="attribute-access-type">[R]</span>
- </div>
- <div class="method-description">
- <p>Some document comment about bar.</p>
+ <div class="aliases">
+ Also aliased as: <a href="Foo.html#method-i-baz">baz</a>
</div>
</div>
</section>
@@ -126,6 +121,21 @@
<h3>Public Instance Methods</h3>
</header>
+ <div id="method-i-baz" class="method-detail">
+ <div class="method-heading attribute-method-heading">
+ <span class="method-name">baz</span><span
+ class="method-args">()</span>
+ </div>
+
+ <div class="method-description">
+ <p>Some document comment about baz.</p>
+ </div>
+
+ <div class="aliases">
+ Alias for: <a href="Foo.html#attribute-i-bar">bar</a>
+ </div>
+ </div>
+
<div id="method-i-quux" class="method-detail method-alias">
<div class="method-header">
<div class="method-heading">
Hi. Can I work on this issue?
@extern-c If you would like to, please do! Feel free to ping me if you want to ask any questions or talk about any ideas.