Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Types and providers fixes #60

Merged
merged 3 commits into from
Sep 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
7 changes: 5 additions & 2 deletions lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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