Sha256: 0238c5d6dd3d3ddcad708667703fec9e146115346840c6a249058f5f1bfc7c0d
Contents?: true
Size: 1.21 KB
Versions: 28
Compression:
Stored size: 1.21 KB
Contents
require "yard" module Lookbook class PreviewParser def initialize(paths, tags = nil) @paths = paths @after_parse_callbacks = [] @after_parse_once_callbacks = [] @parsing = false define_tags(tags) YARD::Parser::SourceParser.after_parse_list { run_callbacks } end def parse(files = nil, &block) unless @parsing @parsing = true @after_parse_once_callbacks << block if block files_list = files ? files.select { |file| file.to_s.end_with?(".rb") } : paths YARD::Registry.clear YARD.parse(files_list) end end def after_parse(&block) @after_parse_callbacks << block end def paths PathUtils.normalize_paths(@paths).map { |path| "#{path}/**/*preview.rb" } end protected def callbacks [ *@after_parse_callbacks, *@after_parse_once_callbacks ] end def run_callbacks callbacks.each { |cb| cb.call(YARD::Registry) } @after_parse_once_callbacks = [] @parsing = false end def define_tags(tags = nil) tags.to_h.each do |name, tag| YARD::Tags::Library.define_tag(tag[:label], name, Lookbook::TagProvider) end end end end
Version data entries
28 entries across 28 versions & 1 rubygems