Sha256: 84a2ec20237c7a3c3e8e9529e4bdc67a7a704694c30223df7a6a58d18c9af8c6

Contents?: true

Size: 1.2 KB

Versions: 133

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

# :nocov:
module Primer
  module Yard
    # :nodoc:
    class ComponentRef
      ATTR_DEFAULTS = {
        js: false,
        examples: true,
        published: true,
        form_component: false
      }.freeze

      attr_reader :klass, :attrs

      def initialize(klass, attrs)
        @klass = klass
        @attrs = attrs
      end

      def requires_js?
        @attrs.fetch(:js, ATTR_DEFAULTS[:js])
      end

      def should_have_examples?
        @attrs.fetch(:examples, ATTR_DEFAULTS[:examples])
      end

      def published?
        @attrs.fetch(:published, ATTR_DEFAULTS[:published])
      end

      def form_component?
        @attrs.fetch(:form_component, ATTR_DEFAULTS[:form_component])
      end

      def source_url
        @source_url ||= begin
          path = klass.name.split("::").map(&:underscore).join("/")
          "https://github.com/primer/view_components/tree/main/app/components/#{path}.rb"
        end
      end

      def lookbook_url
        @lookbook_url ||= begin
          path = klass.name.underscore.gsub("_component", "")
          "https://primer.style/view-components/lookbook/inspect/#{path}/default/"
        end
      end
    end
  end
end
# :nocov:

Version data entries

133 entries across 133 versions & 2 rubygems

Version Path
primer_view_components-0.36.5 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.52.2 lib/primer/yard/component_ref.rb
primer_view_components-0.36.4 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.52.1 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.52.0 lib/primer/yard/component_ref.rb
primer_view_components-0.36.3 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.51.0 lib/primer/yard/component_ref.rb
primer_view_components-0.36.2 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.50.1 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.50.0 lib/primer/yard/component_ref.rb
primer_view_components-0.36.1 lib/primer/yard/component_ref.rb
primer_view_components-0.36.0 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.49.2 lib/primer/yard/component_ref.rb
primer_view_components-0.35.2 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.49.1 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.49.0 lib/primer/yard/component_ref.rb
primer_view_components-0.35.1 lib/primer/yard/component_ref.rb
primer_view_components-0.35.0 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.48.2 lib/primer/yard/component_ref.rb
openproject-primer_view_components-0.48.1 lib/primer/yard/component_ref.rb