55require 'puppet-strings/yard/code_objects'
66require 'puppet-strings/yard/util'
77
8- # Implements the handler for Puppet resource type newparam/newproperty calls written in Ruby.
8+ # Implements the handler for Puppet resource type newparam/newproperty/ensurable calls written in Ruby.
99class PuppetStrings ::Yard ::Handlers ::Ruby ::TypeExtrasHandler < PuppetStrings ::Yard ::Handlers ::Ruby ::TypeBase
1010 # The default docstring when ensurable is used without given a docstring.
1111 DEFAULT_ENSURABLE_DOCSTRING = 'The basic property that the resource should be in.'
1212
1313 namespace_only
1414 handles method_call ( :newparam )
1515 handles method_call ( :newproperty )
16+ handles method_call ( :ensurable )
1617
1718 process do
1819
@@ -38,9 +39,15 @@ class PuppetStrings::Yard::Handlers::Ruby::TypeExtrasHandler < PuppetStrings::Ya
3839 method1_name = statement [ 0 ] . children . drop ( 1 ) . find { |c | c . type == :ident } . source
3940 return unless [ 'Type' , 'Puppet::Type' ] . include? ( module_name ) && method1_name == 'type'
4041
42+ # ensurable is syntatic sugar for newproperty
4143 typename = get_name ( statement [ 0 ] , 'Puppet::Type.type' )
42- method2_name = caller_method
43- propertyname = get_name ( statement , "Puppet::Type.type().#{ method2_name } " )
44+ if caller_method == 'ensurable'
45+ method2_name = 'newproperty'
46+ propertyname = 'ensure'
47+ else
48+ method2_name = caller_method
49+ propertyname = get_name ( statement , "Puppet::Type.type().#{ method2_name } " )
50+ end
4451
4552 typeobject = get_type_yard_object ( typename )
4653
0 commit comments