Class: Primer::Yard::LookbookPagesBackend

Inherits:
Backend
  • Object
show all
Defined in:
lib/primer/yard/lookbook_pages_backend.rb

Overview

Backend that generates Lookbook pages.

Constant Summary collapse

IGNORED_COMPONENTS =
[
  Primer::Alpha::FormControl
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DocsHelper

#link_to_accessibility, #link_to_component, #link_to_heading_practices, #link_to_octicons, #link_to_system_arguments_docs, #link_to_typography_docs, #one_of, #pretty_default_value, #pretty_value, #status_module_and_short_name

Constructor Details

#initialize(registry, manifest) ⇒ LookbookPagesBackend

Returns a new instance of LookbookPagesBackend.



174
175
176
177
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 174

def initialize(registry, manifest)
  @registry = registry
  @manifest = manifest
end

Instance Attribute Details

#manifestObject (readonly)

Returns the value of attribute manifest.



166
167
168
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 166

def manifest
  @manifest
end

#registryObject (readonly)

Returns the value of attribute registry.



166
167
168
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 166

def registry
  @registry
end

Instance Method Details

#generateObject



179
180
181
182
183
184
185
186
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 179

def generate
  each_component do |component_ref|
    next if IGNORED_COMPONENTS.include?(component_ref.klass)

    page_for(component_ref).generate
  end
  generate_system_args_docs
end

#page_for(component_ref) ⇒ Object



188
189
190
191
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 188

def page_for(component_ref)
  docs = registry.find(component_ref.klass)
  LookbookPage.new(component_ref, self, docs)
end

#view_contextObject



193
194
195
196
197
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 193

def view_context
  @view_context ||= super.tap do |vc|
    vc.singleton_class.include(LookbookDocsHelper)
  end
end