module Puppet::Interface::FullDocs
This module can be mixed in to provide a full set of documentation attributes. It is intended to be used for {Puppet::Interface}. @api public
Attributes
Sets the copyright owner @param value [String, Array<String>] The copyright owner or
owners.
@return [String] Comma-separated list of copyright owners @api private
Sets the copyright year @param value [Integer, Range<Integer>, Array<Integer, Range>] The
copyright year or years.
@return [String] @api private
Public Instance Methods
Sets the copyright owner and year. This returns the copyright string, so it can be called with no arguments retrieve that string without side effects. @param owner [String, Array<String>] The copyright owner or an
array of owners
@param years [Integer, Range<Integer>, Array<Integer,Range<Integer>>]
The copyright year or years. Years can be specified with integers, a range of integers, or an array of integers and ranges of integers.
@return [String] A string describing the copyright on this object. @api public @dsl Faces
# File lib/puppet/interface/documentation.rb 249 def copyright(owner = nil, years = nil) 250 if years.nil? and not owner.nil? then 251 #TRANSLATORS 'copyright' is an attribute name and should not be translated 252 raise ArgumentError, _('copyright takes the owners names, then the years covered') 253 end 254 self.copyright_owner = owner unless owner.nil? 255 self.copyright_years = years unless years.nil? 256 257 if self.copyright_years or self.copyright_owner then 258 "Copyright #{self.copyright_years} by #{self.copyright_owner}" 259 else 260 "Unknown copyright owner and years." 261 end 262 end
# File lib/puppet/interface/documentation.rb 270 def copyright_owner=(value) 271 case value 272 when String then @copyright_owner = value 273 when Array then @copyright_owner = value.join(", ") 274 else 275 #TRANSLATORS 'copyright' is an attribute name and should not be translated 276 raise ArgumentError, _("copyright owner must be a string or an array of strings") 277 end 278 @copyright_owner 279 end
# File lib/puppet/interface/documentation.rb 287 def copyright_years=(value) 288 years = munge_copyright_year value 289 years = (years.is_a?(Array) ? years : [years]). 290 sort_by do |x| x.is_a?(Range) ? x.first : x end 291 292 @copyright_years = years.map do |year| 293 if year.is_a? Range then 294 "#{year.first}-#{year.last}" 295 else 296 year 297 end 298 end.join(", ") 299 end
@api private
# File lib/puppet/interface/documentation.rb 302 def munge_copyright_year(input) 303 case input 304 when Range then input 305 when Integer then 306 if input < 1970 then 307 fault = "before 1970" 308 elsif input > (future = Time.now.year + 2) then 309 fault = "after #{future}" 310 end 311 if fault then 312 #TRANSLATORS 'copyright' is an attribute name and should not be translated 313 raise ArgumentError, _("copyright with a year %{value} is very strange; did you accidentally add or subtract two years?") % 314 { value: fault } 315 end 316 317 input 318 319 when String then 320 input.strip.split(/,/).map do |part| 321 part = part.strip 322 if part =~ /^\d+$/ 323 part.to_i 324 else 325 found = part.split(/-/) 326 if found 327 unless found.length == 2 and found.all? {|x| x.strip =~ /^\d+$/ } 328 #TRANSLATORS 'copyright' is an attribute name and should not be translated 329 raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect } 330 end 331 Range.new(found[0].to_i, found[1].to_i) 332 else 333 #TRANSLATORS 'copyright' is an attribute name and should not be translated 334 raise ArgumentError, _("%{value} is not a good copyright year or range") % { value: part.inspect } 335 end 336 end 337 end 338 339 when Array then 340 result = [] 341 input.each do |item| 342 item = munge_copyright_year item 343 if item.is_a? Array 344 result.concat item 345 else 346 result << item 347 end 348 end 349 result 350 351 else 352 #TRANSLATORS 'copyright' is an attribute name and should not be translated 353 raise ArgumentError, _("%{value} is not a good copyright year, set, or range") % { value: input.inspect } 354 end 355 end
@overload short_description
(value)
Sets a short description for this object. @param value [String, nil] A short description (about a paragraph) of this component. If `value` is `nil` the short_description will be set to the shorter of the first paragraph or the first five lines of {description}. @return [void] @api public @dsl Faces
@overload short_description
Get the short description for this object @return [String, nil] The short description of this object. If none is set it will be derived from {description}. Returns `nil` if {description} is `nil`. @api private
# File lib/puppet/interface/documentation.rb 178 def short_description(value = nil) 179 self.short_description = value unless value.nil? 180 if @short_description.nil? then 181 return nil if @description.nil? 182 lines = @description.split("\n") 183 first_paragraph_break = lines.index('') || 5 184 grab = [5, first_paragraph_break].min 185 @short_description = lines[0, grab].join("\n") 186 @short_description += ' [...]' if (grab < lines.length and first_paragraph_break >= 5) 187 end 188 @short_description 189 end