Merge pull request #60 from iankronquist/types-and-providers-fixes

Types and providers fixes
This commit is contained in:
Hailee Kenney 2015-09-15 15:38:47 -07:00
commit 7c109b231b
3 changed files with 8 additions and 5 deletions

View File

@ -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`
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
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
@ -174,7 +174,7 @@ directive `@!puppet.provider.param` which may take types, the parameter name,
and a description.
```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
Puppet::Type.newtype(:minifile) do

View File

@ -138,9 +138,12 @@ class PuppetX::PuppetLabs::Strings::YARD::Handlers::PuppetTypeHandler < YARD::Ha
obj.property_details = property_details
obj.features = features
register_docstring(obj, docstring, nil)
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

View File

@ -3,7 +3,7 @@ require 'puppet_x/puppetlabs/strings/yard/core_ext/yard'
class PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetTypeParameterDirective < YARD::Tags::Directive
def call
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}
end
end