Sha256: a691e694c38d1f6daeca6f9c097a181fea02c5ec223d6a59b17f1d7073e6b74e

Contents?: true

Size: 832 Bytes

Versions: 5

Compression:

Stored size: 832 Bytes

Contents

require "yard"

module Lookbook
  class Parser
    YARDOC_FILE_PATH = Rails.root.join("tmp/storage/.yardoc").to_s

    def initialize(paths)
      @paths = paths.map { |p| "#{p}/**/*_preview.rb" }
      YARD::Registry.yardoc_file = YARDOC_FILE_PATH
    end

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

    def get_code_object(path)
      registry = YARD::RegistryStore.new
      registry.load!(YARDOC_FILE_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)
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lookbook-0.4.3 lib/lookbook/parser.rb
lookbook-0.4.2 lib/lookbook/parser.rb
lookbook-0.4.1 lib/lookbook/parser.rb
lookbook-0.4.0.beta.2 lib/lookbook/parser.rb
lookbook-0.4.0.beta.1 lib/lookbook/parser.rb