yard
yard copied to clipboard
Class attributes shown as inherited when namespace is included
When a mixin with one or more class attributes is included (not extended) elsewhere, any class attributes are shown as "extended from" in the destination when --embed-mixins
is used.
(As an aside, --embed-mixins
only seems to work with yard server
if it is in a .yardopts
file... is this intentional?)
Steps to reproduce
module TestMixin
class << self
attr_reader :some_attribute
end
end
class TestClass
include TestMixin
end
This is the minimal reproduction for the issue. I've done my best to remove all extraneous code and unique environment state on my machine before providing these steps:
- Run the following command:
yard doc --embed-mixins
- Open the resulting doc/TestClass.html file
Actual Output
The class attribute from the mixin is shown in the class that included it.
Expected Output
The attribute should not be shown in the class because it does not exist.
Environment details:
- OS: Windows 10
- Ruby version (
ruby -v
): ruby 2.4.4p296 (2018-03-28 revision 63013) [x64-mingw32] - YARD version (
yard -v
): yard 0.9.15
I have read the Contributing Guide.
Actually, why does it ever do anything with class attributes and inheritance? Is there some scenario where class attributes / methods on a module become available to an inheriting class? Unless I'm missing something, there doesn't seem to be...
This also doesn't appear to be limited to class attributes with --embed-mixins
. Given the following code, with and without --embed mixins produces varying results (neither of which are completely correct):
module TestMixin
class << self
attr_reader :mixin_class_attribute
def mixin_class_method; end
end
attr_reader :mixin_instance_attribute
def mixin_instance_method; end
end
class IncludeTestClass
include TestMixin
end
class ExtendTestClass
extend TestMixin
end
I've summarized the output in this gist: https://gist.github.com/rintaun/d2dd8703aee70737c625515b2a0c966b