module Puppet::Interface::DocGen

@api private

Public Class Methods

strip_whitespace(text) click to toggle source

@api private

   # File lib/puppet/interface/documentation.rb
 8 def self.strip_whitespace(text)
 9   # I don't want no...
10   Puppet::Util::Docs.scrub(text)
11 end

Public Instance Methods

attr_doc(name, &validate) click to toggle source

@api private

   # File lib/puppet/interface/documentation.rb
22     def attr_doc(name, &validate)
23       # Now, which form of the setter do we want, validated or not?
24       get_arg = "value.to_s"
25       if validate
26         define_method(:"_validate_#{name}", validate)
27         get_arg = "_validate_#{name}(#{get_arg})"
28       end
29 
30       # We use module_eval, which I don't like much, because we can't have an
31       # argument to a block with a default value in Ruby 1.8, and I don't like
32       # the side-effects (eg: no argument count validation) of using blocks
33       # without as methods.  When we are 1.9 only (hah!) you can totally
34       # replace this with some up-and-up define_method. --daniel 2011-04-29
35       module_eval(<<-EOT, __FILE__, __LINE__ + 1)
36         def #{name}(value = nil)
37           self.#{name} = value unless value.nil?
38           @#{name}
39         end
40 
41         def #{name}=(value)
42           @#{name} = Puppet::Interface::DocGen.strip_whitespace(#{get_arg})
43         end
44       EOT
45     end