Merge pull request #60 from iankronquist/types-and-providers-fixes
Types and providers fixes
This commit is contained in:
commit
7c109b231b
|
@ -165,7 +165,7 @@ Here's an example of how you might document a class:
|
||||||
Strings will automatically extract the `@doc` provider docstring and any `desc`
|
Strings will automatically extract the `@doc` provider docstring and any `desc`
|
||||||
parameter/property docstrings.
|
parameter/property docstrings.
|
||||||
|
|
||||||
Sometimes however, Puppet providers use metaprogramming to create parameters
|
Sometimes however, Puppet types use metaprogramming to create parameters
|
||||||
and methods automatically. In those cases Strings will not be able to document
|
and methods automatically. In those cases Strings will not be able to document
|
||||||
them automatically (Strings doesn't execute the code that would generate those
|
them automatically (Strings doesn't execute the code that would generate those
|
||||||
parameters), so you will need to provide hints on how to document your code. To
|
parameters), so you will need to provide hints on how to document your code. To
|
||||||
|
@ -174,7 +174,7 @@ directive `@!puppet.provider.param` which may take types, the parameter name,
|
||||||
and a description.
|
and a description.
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
# @!puppet.provider.param my_parameter This parameter needs to be explicitly
|
# @!puppet.type.param my_parameter This parameter needs to be explicitly
|
||||||
# documented as it is generated by mk_resource_methods
|
# documented as it is generated by mk_resource_methods
|
||||||
Puppet::Type.newtype(:minifile) do
|
Puppet::Type.newtype(:minifile) do
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,12 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetTypeHandler < YARD::Ha
|
||||||
obj.property_details = property_details
|
obj.property_details = property_details
|
||||||
obj.features = features
|
obj.features = features
|
||||||
|
|
||||||
register_docstring(obj, docstring, nil)
|
|
||||||
|
|
||||||
register obj
|
register obj
|
||||||
|
# Register docstring after the object. If the object already has a
|
||||||
|
# docstring, or more likely has parameters documented with the type
|
||||||
|
# directive and an empty docstring, we want to override it with the
|
||||||
|
# docstring we found, assuming we found one.
|
||||||
|
register_docstring(obj, docstring, nil) if docstring
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ require 'puppet_x/puppetlabs/strings/yard/core_ext/yard'
|
||||||
class PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetTypeParameterDirective < YARD::Tags::Directive
|
class PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetTypeParameterDirective < YARD::Tags::Directive
|
||||||
def call
|
def call
|
||||||
return if object.nil?
|
return if object.nil?
|
||||||
object.parameters << ([tag.text] + tag.types)
|
object.parameters << ([tag.text, tag.types].flatten)
|
||||||
object.parameter_details << {:name => tag.name, :desc => tag.text, :exists? => true, :puppet_type => true}
|
object.parameter_details << {:name => tag.name, :desc => tag.text, :exists? => true, :puppet_type => true}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue