diff --git a/README.md b/README.md index 7c0862ab8..7e10275af 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb b/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb index d146e6f2d..06c7d342e 100644 --- a/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb +++ b/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb @@ -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 diff --git a/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb b/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb index dcb60e084..0b9479306 100644 --- a/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb +++ b/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb @@ -3,7 +3,7 @@ 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