Issue #8426 has been updated by Nick Fagerlund.

After consulting with James, Jacob, and Nick1, this turned out to be somewhat 
impossible. Check it out:

    class << self
      ...
      # Define the default value for a given parameter or parameter.  This
      # means that 'nil' is an invalid default value.  This defines
      # the 'default' instance method.
      def defaultto(value = nil, &block)
        if block
          define_method(:default, &block)
        else
          if value.nil?
            raise Puppet::DevError,
              "Either a default value or block must be provided"
          end
          define_method(:default) do value end
        end
      end

At first I thought we could just call self.default from the doc method when 
we're building the string, but it's actually adding that method to instances of 
the parameter contained within a resource instance, not to the parameter class. 
So the default doesn't exist until a specific resource of the relevant type is 
instantiated; that's what all the business with the block is about, is so you 
can make defaults that are just completely dependent on the environment where 
the resource is declared. Which makes guessing the default impossible without 
knowing the environment. 

About the best we could do is grep the code for a "defaultto" method call and 
dump the actual text of the block; let's not do that yet. 

I'm not sure how to proceed here, but am reluctant to close the bug. 
----------------------------------------
Bug #8426: Type reference generator should integrate parameters' 
`defaultto`value
https://projects.puppetlabs.com/issues/8426

Author: Nick Fagerlund
Status: Accepted
Priority: Normal
Assignee: 
Category: 
Target version: 
Affected Puppet version: 
Keywords: 
Branch: 


Ticket #5108 made a disruptively incompatible change to the way the service 
type works, and the docs were never updated accordingly. This slipped past 
everyone until it came up in the IRC channel. 

Disruptive defaults changes should always show up in the release notes, but 
this could have been less problematic if the type reference showed default 
values; that way, the change would have showed up even without being 
consciously documented and the user could have compared the new value to the 
old one. We should make that happen. 


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-bugs?hl=en.

Reply via email to