Class: Bake::Documentation
- Inherits:
-
Object
- Object
- Bake::Documentation
- Defined in:
- lib/bake/documentation.rb
Constant Summary collapse
- DESCRIPTION =
/\A\s*([^@\s].*)?\z/
- ATTRIBUTE =
/\A\s*@(?<name>.*?)\s+(?<value>.*?)\z/
- PARAMETER =
/\A\s*@param\s+(?<name>.*?)\s+\[(?<type>.*?)\]\s+(?<details>.*?)\z/
Instance Method Summary collapse
- #attributes ⇒ Object
- #description ⇒ Object
-
#initialize(comments) ⇒ Documentation
constructor
A new instance of Documentation.
- #parameters ⇒ Object
Constructor Details
#initialize(comments) ⇒ Documentation
Returns a new instance of Documentation.
26 27 28 |
# File 'lib/bake/documentation.rb', line 26 def initialize(comments) @comments = comments end |
Instance Method Details
#attributes ⇒ Object
58 59 60 61 62 63 64 65 66 |
# File 'lib/bake/documentation.rb', line 58 def attributes return to_enum(:attributes) unless block_given? @comments.each do |comment| if match = comment.match(ATTRIBUTE) yield match end end end |
#description ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bake/documentation.rb', line 32 def description return to_enum(:description) unless block_given? # We track empty lines and only yield a single empty line when there is another line of text: gap = false @comments.each do |comment| if match = comment.match(DESCRIPTION) if match[1] if gap yield "" gap = false end yield match[1] else gap = true end else break end end end |
#parameters ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'lib/bake/documentation.rb', line 70 def parameters return to_enum(:parameters) unless block_given? @comments.each do |comment| if match = comment.match(PARAMETER) yield match end end end |