Class: KafoParsers::DocParser
- Inherits:
-
Object
- Object
- KafoParsers::DocParser
- Defined in:
- lib/kafo_parsers/doc_parser.rb
Defined Under Namespace
Classes: Nesting
Constant Summary collapse
- ATTRIBUTE_LINE =
/^(condition|type)\s*:\s*(.*)/
- HEADER_CONDITION =
/\A(.+)\s*condition:\s*(.+)\Z/
Instance Attribute Summary collapse
-
#conditions ⇒ Object
readonly
Returns the value of attribute conditions.
-
#docs ⇒ Object
readonly
Returns the value of attribute docs.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
-
#types ⇒ Object
readonly
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(text) ⇒ DocParser
constructor
A new instance of DocParser.
-
#parse(items = @rdoc.parts) ⇒ Object
items is array of RDoc::Markup::* on one level.
Constructor Details
#initialize(text) ⇒ DocParser
Returns a new instance of DocParser.
13 14 15 16 17 18 19 20 21 |
# File 'lib/kafo_parsers/doc_parser.rb', line 13 def initialize(text) @text = text @nesting_buffer = [] @docs = {} @groups = {} @conditions = {} @types = {} @rdoc = rdoc_parser.parse(@text) end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
23 24 25 |
# File 'lib/kafo_parsers/doc_parser.rb', line 23 def conditions @conditions end |
#docs ⇒ Object (readonly)
Returns the value of attribute docs.
23 24 25 |
# File 'lib/kafo_parsers/doc_parser.rb', line 23 def docs @docs end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
23 24 25 |
# File 'lib/kafo_parsers/doc_parser.rb', line 23 def groups @groups end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
23 24 25 |
# File 'lib/kafo_parsers/doc_parser.rb', line 23 def types @types end |
Instance Method Details
#parse(items = @rdoc.parts) ⇒ Object
items is array of RDoc::Markup::* on one level
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/kafo_parsers/doc_parser.rb', line 26 def parse(items = @rdoc.parts) items.each do |item| if item.is_a?(RDoc::Markup::Heading) parse_header(item) elsif item.is_a?(RDoc::Markup::List) && item.respond_to?(:items) parse(item.items) elsif item.is_a?(RDoc::Markup::ListItem) parse_paragraph(item) end end self end |