Class: DocGen::Context
- Inherits:
-
Struct
- Object
- Struct
- DocGen::Context
- Defined in:
- lib/doc_gen/parser.rb
Overview
A context represents a ‘describe` block. It holds child contexts and specs.
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#docstring ⇒ Object
Returns the value of attribute docstring.
-
#file ⇒ Object
Returns the value of attribute file.
-
#line ⇒ Object
Returns the value of attribute line.
-
#name ⇒ Object
Returns the value of attribute name.
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#full_name ⇒ Object
Full display name, dropping the root component when nested.
-
#output_path ⇒ Object
Hierarchical output path relative to the output directory root.
-
#specs ⇒ Object
Direct child specs (it/specify blocks).
-
#subcontexts ⇒ Object
Direct child contexts (nested describe blocks).
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children
15 16 17 |
# File 'lib/doc_gen/parser.rb', line 15 def children @children end |
#docstring ⇒ Object
Returns the value of attribute docstring
15 16 17 |
# File 'lib/doc_gen/parser.rb', line 15 def docstring @docstring end |
#file ⇒ Object
Returns the value of attribute file
15 16 17 |
# File 'lib/doc_gen/parser.rb', line 15 def file @file end |
#line ⇒ Object
Returns the value of attribute line
15 16 17 |
# File 'lib/doc_gen/parser.rb', line 15 def line @line end |
#name ⇒ Object
Returns the value of attribute name
15 16 17 |
# File 'lib/doc_gen/parser.rb', line 15 def name @name end |
#parent ⇒ Object
Returns the value of attribute parent
15 16 17 |
# File 'lib/doc_gen/parser.rb', line 15 def parent @parent end |
Instance Method Details
#full_name ⇒ Object
Full display name, dropping the root component when nested. Examples:
root 'Site::Tlc::Io' => 'Site::Tlc::Io'
child 'IO' of above => 'IO'
grandchild 'Input' of above => 'IO Input'
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/doc_gen/parser.rb', line 31 def full_name parts = [name] ctx = parent while ctx.is_a?(Context) parts.unshift(ctx.name) ctx = ctx.parent end parts.shift if parts.size > 1 parts.join(' ') end |
#output_path ⇒ Object
Hierarchical output path relative to the output directory root. Examples:
root 'Site::Tlc::Io' => 'site_tlc_io.md'
child 'IO' => 'site_tlc_io/io.md'
grandchild 'Input' => 'site_tlc_io/io/input.md'
47 48 49 50 51 52 53 54 55 |
# File 'lib/doc_gen/parser.rb', line 47 def output_path parts = [] ctx = self while ctx.is_a?(Context) parts.unshift(DocGen.slugify(ctx.name)) ctx = ctx.parent end "#{parts.join('/')}.md" end |
#specs ⇒ Object
Direct child specs (it/specify blocks).
17 18 19 |
# File 'lib/doc_gen/parser.rb', line 17 def specs children.grep(Spec) end |
#subcontexts ⇒ Object
Direct child contexts (nested describe blocks).
22 23 24 |
# File 'lib/doc_gen/parser.rb', line 22 def subcontexts children.grep(Context) end |