Class: Tap::Support::TDoc::ConfigAttr
- Defined in:
- lib/tap/support/tdoc.rb
Overview
Encasulates information about the configuration. Designed to be utilized by the TDocHTMLGenerator as similarly as possible to standard attributes.
Instance Attribute Summary collapse
-
#config_declaration ⇒ Object
Contains the actual declaration for the config attribute.
-
#default ⇒ Object
Contains the actual declaration for the config attribute.
Instance Method Summary collapse
-
#comment(add_default = true) ⇒ Object
The description for the config.
- #desc ⇒ Object
-
#initialize(*args) ⇒ ConfigAttr
constructor
A new instance of ConfigAttr.
- #original_comment ⇒ Object
Constructor Details
#initialize(*args) ⇒ ConfigAttr
Returns a new instance of ConfigAttr.
141 142 143 144 |
# File 'lib/tap/support/tdoc.rb', line 141 def initialize(*args) @comment = nil # suppress a warning in Ruby 1.9 super end |
Instance Attribute Details
#config_declaration ⇒ Object
Contains the actual declaration for the config attribute. ex: “c [:key, ‘value’] # comment”
139 140 141 |
# File 'lib/tap/support/tdoc.rb', line 139 def config_declaration @config_declaration end |
#default ⇒ Object
Contains the actual declaration for the config attribute. ex: “c [:key, ‘value’] # comment”
139 140 141 |
# File 'lib/tap/support/tdoc.rb', line 139 def default @default end |
Instance Method Details
#comment(add_default = true) ⇒ Object
The description for the config. Comment is formed from the standard attribute comment and the text following the attribute, which is slightly different than normal:
# standard comment
attr_accessor :attribute
# standard comment
config_accessor :config # ...added to standard comment
c [:key, 'value'] # hence you can comment inline like this.
The comments for each of these will be:
- attribute
-
standard comment
- config
-
standard comment …added to standard comment
- key
-
hence you can comment inline like this.
174 175 176 177 178 179 180 181 |
# File 'lib/tap/support/tdoc.rb', line 174 def comment(add_default=true) # this would include the trailing comment... # text_comment = text.to_s.sub(/^#--.*/m, '') #original_comment.to_s + text_comment + (default && add_default ? " (#{default})" : "") comment = original_comment.to_s.strip comment = desc.to_s if comment.empty? comment + (default && add_default ? " (<tt>#{default}</tt>)" : "") end |
#desc ⇒ Object
148 149 150 151 152 153 154 155 |
# File 'lib/tap/support/tdoc.rb', line 148 def desc case text.to_s when /^#--(.*)/ then $1.strip when /^#(.*)/ then $1.strip else nil end end |
#original_comment ⇒ Object
146 |
# File 'lib/tap/support/tdoc.rb', line 146 alias original_comment comment |