Skip to content

Instantly share code, notes, and snippets.

@rintaun
Created July 29, 2018 14:03
Show Gist options
  • Save rintaun/d2dd8703aee70737c625515b2a0c966b to your computer and use it in GitHub Desktop.
Save rintaun/d2dd8703aee70737c625515b2a0c966b to your computer and use it in GitHub Desktop.
YARD handles inheritance very strangely. Enabling --embed-mixins changes what is shown as included/extended, but with or without, the output is incorrect.
# frozen_string_literal: true
# Test mixin
#
# {.mixin_class_attribute} and {.mixin_class_method} _never_ end up accessible
# in the inheriting class.
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
# Includes the mixin
#
# == Actual Results
# === Class methods/attributes
# (none)
#
# === Instance methods/attributes
# * {TestMixin#mixin_instance_attribute}
# * {TestMixin#mixin_instance_method}
#
# == With --embed-mixins
# === Class methods/attributes
# * {TestMixin.mixin_class_attribute} (bad)
#
# === Instance methods/attributes
# * {TestMixin#mixin_instance_attribute}
# * {TestMixin#mixin_instance_method}
#
# == Without --embed-mixins
# === Class methods/attributes
# * {TestMixin.mixin_class_method} (bad)
#
# === Instance methods/attributes
# * {TestMixin#mixin_instance_attribute}
# * {TestMixin#mixin_instance_method}
class IncludeTestClass
include TestMixin
end
# Extends the mixin
#
# == Actual Results
# === Class methods/attributes
# * {TestMixin#mixin_instance_attribute}
# * {TestMixin#mixin_instance_method}
#
# === Instance methods/attributes
# (none)
#
# == With --embed-mixins
# === Class methods/attributes
# * {TestMixin.mixin_class_attribute} (bad)
# * {TestMixin#mixin_instance_method}
#
# === Instance methods/attributes
# * {TestMixin#mixin_instance_attribute} (bad, should be class attribute)
#
# == Without --embed-mixins
# === Class methods/attributes
# * {TestMixin.mixin_class_method} (bad)
# * {TestMixin#mixin_instance_method}
#
# === Instance methods/attributes
# * {TestMixin#mixin_instance_attribute} (bad, should be class attribute)
class ExtendTestClass
extend TestMixin
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment