Class: CDoc::ConfigAttr

Inherits:
RDoc::Attr
  • Object
show all
Defined in:
lib/cdoc.rb

Overview

Encasulates information about the configuration. Designed to be utilized by the CDocHTMLGenerator as similarly as possible to standard attributes.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ ConfigAttr

Returns a new instance of ConfigAttr.



146
147
148
149
# File 'lib/cdoc.rb', line 146

def initialize(*args)
  @comment = nil # suppress a warning in Ruby 1.9

  super
end

Instance Attribute Details

#config_declarationObject

Contains the actual declaration for the config attribute. ex: “c [:key, ‘value’] # comment”



144
145
146
# File 'lib/cdoc.rb', line 144

def config_declaration
  @config_declaration
end

#defaultObject

Contains the actual declaration for the config attribute. ex: “c [:key, ‘value’] # comment”



144
145
146
# File 'lib/cdoc.rb', line 144

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.



179
180
181
182
183
184
185
186
# File 'lib/cdoc.rb', line 179

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

#descObject



153
154
155
156
157
158
159
160
# File 'lib/cdoc.rb', line 153

def desc
  case text.to_s 
  when /^#--(.*)/ then $1.strip
  when /^#(.*)/ then $1.strip
  else
    nil
  end
end

#original_commentObject



151
# File 'lib/cdoc.rb', line 151

alias original_comment comment