(PDOC-35) Document documenting puppet providers

Add instructions on how to use the `@!puppet.provider.param` directive to
document parameters which are created via metaprogramming.
This commit is contained in:
Ian Kronquist 2015-08-11 11:53:01 -07:00
parent 05f489fcee
commit 9b8777c1b4
1 changed files with 33 additions and 0 deletions

View File

@ -158,6 +158,39 @@ And here's an example of how you might document a class:
) { }
```
Puppet providers often rely on different types of metaprogramming to create
parameters and methods. Since Strings does not execute the code which is being
documented you must provide hints on how to document your code. To document a
parameter which is automatically created you must use the special directive
`@!puppet.provider.param` Which may take types, the parameter name, and a
description.
Strings will automatically extract the `@doc` provider docstring and any `desc`
parameter docstrings.
```ruby
# @!puppet.provider.param my_parameter This parameter needs to be explicitly
# documented
Puppet::Type.newtype(:minifile) do
@doc = "Manages files, including their content, ownership, and permissions.
The provider can manage symbolic links."
# This function does some metaprogramming on the new type.
mk_resource_methods
newparam(:path) do
desc <<-'EOT'
The path to the file to manage. Must be fully qualified.
EOT
# ... do stuff here
end
# ...
end
```
Here are a few other good resources for getting started with documentation:
* [Module README Template](https://docs.puppetlabs.com/puppet/latest/reference/modules_documentation.html)