Class: ViewComponent::Storybook::StoriesParser

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component/storybook/stories_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ StoriesParser

Returns a new instance of StoriesParser.



8
9
10
11
12
13
14
15
# File 'lib/view_component/storybook/stories_parser.rb', line 8

def initialize(paths)
  @paths = paths
  @after_parse_callbacks = []
  @after_parse_once_callbacks = []
  @parsing = false

  YARD::Parser::SourceParser.after_parse_list { run_callbacks }
end

Instance Attribute Details

#pathsObject (readonly)

Returns the value of attribute paths.



30
31
32
# File 'lib/view_component/storybook/stories_parser.rb', line 30

def paths
  @paths
end

Instance Method Details

#after_parse(&block) ⇒ Object



26
27
28
# File 'lib/view_component/storybook/stories_parser.rb', line 26

def after_parse(&block)
  @after_parse_callbacks << block
end

#parse(&block) ⇒ Object



17
18
19
20
21
22
23
24
# File 'lib/view_component/storybook/stories_parser.rb', line 17

def parse(&block)
  return if @parsing

  @parsing = true
  @after_parse_once_callbacks << block if block
  YARD::Registry.clear
  YARD.parse(paths)
end