Class: StimulusPlumbers::MCP::DocsTableParser

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_plumbers/mcp/loaders/support/docs_table_parser.rb

Class Method Summary collapse

Class Method Details

.call(content) ⇒ Object



7
8
9
10
# File 'lib/stimulus_plumbers/mcp/loaders/support/docs_table_parser.rb', line 7

def call(content)
  tables = tables_with_headings(content)
  { helpers: option_helpers(tables), slots: slot_methods(tables) }
end

.tables_with_headings(content) ⇒ Object

A standalone bold label (e.g. **Time**) between # headings is treated as a sub-heading, since some docs use one to introduce a table scoped to part of a section. It only labels the single table immediately following it — a fenced code block or a second table both clear it, so it can't leak onto later tables.



16
17
18
19
20
21
# File 'lib/stimulus_plumbers/mcp/loaders/support/docs_table_parser.rb', line 16

def tables_with_headings(content)
  state = { heading: nil, subheading: nil, fenced: false, buffer: [], tables: [] }
  content.each_line { |line| scan_line(line, state) }
  flush_table(state)
  state[:tables]
end