Sha256: 5395bc2f07edcb913bad020f862cd56226a0f78bdf8095adaab6a153ea7e3e53

Contents?: true

Size: 1018 Bytes

Versions: 4

Compression:

Stored size: 1018 Bytes

Contents

require "yard"

module Lookbook
  class Parser
    attr_reader :registry_path
    def initialize(paths, registry_path)
      @paths = paths.map { |p| "#{p}/**/*preview.rb" }
      @registry_path = registry_path.to_s
      YARD::Registry.yardoc_file = registry_path
    end

    def parse
      YARD::Registry.clear
      YARD::Registry.lock_for_writing do
        YARD.parse(@paths)
        YARD::Registry.save(false, registry_path)
      end
    end

    def get_code_object(path)
      registry = YARD::RegistryStore.new
      registry.load!(registry_path)
      registry.get(path)
    end

    class << self
      def define_tags
        YARD::Tags::Library.define_tag("Hidden status", :hidden)
        YARD::Tags::Library.define_tag("Label", :label)
        YARD::Tags::Library.define_tag("Display", :display)
        YARD::Tags::Library.define_tag("Position", :position)
        YARD::Tags::Library.define_tag("ID", :id)
        YARD::Tags::Library.define_tag("Component", :component)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lookbook-1.0.0.beta.6 lib/lookbook/parser.rb
lookbook-1.0.0.beta.5 lib/lookbook/parser.rb
lookbook-1.0.0.beta.4 lib/lookbook/parser.rb
lookbook-1.0.0.beta.3 lib/lookbook/parser.rb