Class: Kafo::DocParser
- Inherits:
-
Object
- Object
- Kafo::DocParser
- Defined in:
- lib/kafo/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.
11 12 13 14 15 16 17 18 19 |
# File 'lib/kafo/doc_parser.rb', line 11 def initialize(text) @text = text @nesting_buffer = [] @docs = {} @groups = {} @conditions = {} @types = Hash.new('string') @rdoc = rdoc_parser.parse(@text) end |
Instance Attribute Details
#conditions ⇒ Object (readonly)
Returns the value of attribute conditions.
21 22 23 |
# File 'lib/kafo/doc_parser.rb', line 21 def conditions @conditions end |
#docs ⇒ Object (readonly)
Returns the value of attribute docs.
21 22 23 |
# File 'lib/kafo/doc_parser.rb', line 21 def docs @docs end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
21 22 23 |
# File 'lib/kafo/doc_parser.rb', line 21 def groups @groups end |
#types ⇒ Object (readonly)
Returns the value of attribute types.
21 22 23 |
# File 'lib/kafo/doc_parser.rb', line 21 def types @types end |
Instance Method Details
#parse(items = @rdoc.parts) ⇒ Object
items is array of RDoc::Markup::* on one level
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/kafo/doc_parser.rb', line 24 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 |