Class: Primer::Yard::LookbookPagesBackend

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

Overview

Backend that generates Lookbook pages.

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.



168
169
170
171
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 168

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



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

def generate
  each_component do |component_ref|
    page_for(component_ref).generate
  end
  generate_system_args_docs
end

#page_for(component_ref) ⇒ Object



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

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

#view_contextObject



185
186
187
188
189
# File 'lib/primer/yard/lookbook_pages_backend.rb', line 185

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