Class: Ariadne::Yard::Registry

Inherits:
Object
  • Object
show all
Extended by:
ViewHelper, DocsHelper, ViewComponent::TestHelpers
Defined in:
lib/ariadne/yard/registry.rb

Overview

Wrapper around an instance of YARD::Registry that provides easy access to component documentation.

Constant Summary

Constants included from ViewHelper

ViewHelper::HELPERS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from DocsHelper

component_and_short_name, link_to_accessibility, link_to_component, link_to_heading_practices, link_to_heroicons, link_to_html_attrs_docs, link_to_typography_docs, one_of, pretty_default_value, pretty_value

Constructor Details

#initialize(yard_registry) ⇒ Registry

Returns a new instance of Registry.



113
114
115
# File 'lib/ariadne/yard/registry.rb', line 113

def initialize(yard_registry)
  @yard_registry = yard_registry
end

Instance Attribute Details

#yard_registryObject (readonly)

Returns the value of attribute yard_registry.



111
112
113
# File 'lib/ariadne/yard/registry.rb', line 111

def yard_registry
  @yard_registry
end

Class Method Details

.makeObject



103
104
105
106
107
108
# File 'lib/ariadne/yard/registry.rb', line 103

def make
  registry = ::YARD::RegistryStore.new
  registry.load!(File.expand_path(File.join("..", "..", "..", ".yardoc"), __dir__))

  new(registry)
end

Instance Method Details

#find(component) ⇒ Object



117
118
119
120
121
122
123
# File 'lib/ariadne/yard/registry.rb', line 117

def find(component)
  return entries[component] if entries.include?(component)

  return unless (docs = yard_registry.get(component.name))

  entries[component] = RegistryEntry.new(component, docs)
end