Class: Primer::Yard::RegistryEntry
  
  
  
  
  
    - Inherits:
 
    - 
      Object
      
        
          - Object
 
          
            - Primer::Yard::RegistryEntry
 
          
        
        show all
      
     
  
  
  
  
  
  
  
      - Includes:
 
      - DocsHelper
 
  
  
  
  
  
  
    - Defined in:
 
    - lib/primer/yard/registry.rb
 
  
  
 
Overview
  
    
A wrapper around a YARD class reference that provides convenience methods for extracting component parameters, accessibility status, etc.
   
 
  
  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(component, docs)  ⇒ RegistryEntry 
  
  
  
  
    
Returns a new instance of RegistryEntry.
   
 
  
  
    
      
18
19
20
21 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 18
def initialize(component, docs)
  @component = component
  @docs = docs
end 
     | 
  
 
  
 
  
    Instance Attribute Details
    
      
      
      
  
  
    #component  ⇒ Object  
  
  
  
  
    
Returns the value of attribute component.
   
 
  
  
    
      
14
15
16 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 14
def component
  @component
end 
     | 
  
 
    
      
      
      
  
  
    #docs  ⇒ Object  
  
  
  
  
    
Returns the value of attribute docs.
   
 
  
  
    
      
14
15
16 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 14
def docs
  @docs
end 
     | 
  
 
    
   
  
    Instance Method Details
    
      
  
  
    #a11y_reviewed?  ⇒ Boolean 
  
  
  
  
    
      
89
90
91 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 89
def a11y_reviewed?
  metadata[:a11y_reviewed]
end 
     | 
  
 
    
      
  
  
    #component_id  ⇒ Object 
  
  
  
  
    
      
73
74
75 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 73
def component_id
  metadata[:component_id]
end 
     | 
  
 
    
      
  
  
    #constructor  ⇒ Object 
  
  
  
  
    
      
41
42
43 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 41
def constructor
  docs.meths.find(&:constructor?)
end 
     | 
  
 
    
      
  
  
    #manifest_entry  ⇒ Object 
  
  
  
  
    
      
93
94
95 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 93
def manifest_entry
  @manifest_entry ||= ComponentManifest.ref_for(component)
end 
     | 
  
 
    
      
  
  
    
      
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 23
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
     | 
  
 
    
      
  
  
    #non_slot_methods  ⇒ Object 
  
  
  
  
    
      
53
54
55 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 53
def non_slot_methods
  public_methods.reject { |mtd| slot_method?(mtd) }
end
     | 
  
 
    
      
  
  
    #params  ⇒ Object 
  
  
  
  
    
      
45
46
47 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 45
def params
  constructor&.tags(:param) || []
end 
     | 
  
 
    
      
  
  
    #public_methods  ⇒ Object 
  
  
  
  
    
      
61
62
63
64
65
66
67 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 61
def public_methods
      @public_methods ||= docs.meths.reject do |mtd|
    mtd.tag(:private) || mtd.name == :initialize
  end
end
     | 
  
 
    
      
  
  
    #short_name  ⇒ Object 
  
  
  
  
    
      
85
86
87 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 85
def short_name
  metadata[:short_name]
end 
     | 
  
 
    
      
  
  
    #slot_method?(mtd)  ⇒ Boolean 
  
  
  
  
    
      
57
58
59 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 57
def slot_method?(mtd)
  mtd[:renders_one] || mtd[:renders_many]
end 
     | 
  
 
    
      
  
  
    #slot_methods  ⇒ Object 
  
  
  
  
    
      
49
50
51 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 49
def slot_methods
  public_methods.select { |mtd| slot_method?(mtd) }
end
     | 
  
 
    
      
  
  
    #status  ⇒ Object 
  
  
  
  
    
      
77
78
79 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 77
def status
  metadata[:status]
end 
     | 
  
 
    
      
  
  
    #status_module  ⇒ Object 
  
  
  
  
    
      
81
82
83 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 81
def status_module
  metadata[:status_module]
end 
     | 
  
 
    
      
  
  
    #title  ⇒ Object 
  
  
  
  
    
      
69
70
71 
     | 
    
      # File 'lib/primer/yard/registry.rb', line 69
def title
  metadata[:title]
end 
     |