class Primer::Yard::RegistryEntry
for extracting component parameters, accessibility status, etc.
A wrapper around a YARD class reference that provides convenience methods
def a11y_reviewed?
def a11y_reviewed? metadata[:a11y_reviewed] end
def component_id
def component_id metadata[:component_id] end
def constructor
def constructor docs.meths.find(&:constructor?) end
def initialize(component, docs)
def initialize(component, docs) @component = component @docs = docs end
def manifest_entry
def manifest_entry @manifest_entry ||= ComponentManifest.ref_for(component) end
def metadata
def metadata @metadata ||= begin status_module, short_name, class_name = status_module_and_short_name(component) status = component.status.to_s a11y_reviewed = component.audited_at.nil? ? "false" : "true" { title: class_name, class_name: class_name, component_id: short_name.underscore, status: status.capitalize, status_module: status_module, short_name: short_name, a11y_reviewed: a11y_reviewed } end end
def non_slot_methods
def non_slot_methods public_methods.reject { |mtd| slot_method?(mtd) } end
def params
def params constructor&.tags(:param) || [] end
def public_methods
def public_methods # Returns: only public methods that belong to this class (i.e. no inherited methods) # excluding the constructor @public_methods ||= docs.meths.reject do |mtd| mtd.tag(:private) || mtd.name == :initialize end end
def short_name
def short_name metadata[:short_name] end
def slot_method?(mtd)
def slot_method?(mtd) mtd[:renders_one] || mtd[:renders_many] end
def slot_methods
def slot_methods public_methods.select { |mtd| slot_method?(mtd) } end
def status
def status metadata[:status] end
def status_module
def status_module metadata[:status_module] end
def title
def title metadata[:title] end