forked from puppetlabs/puppet-strings
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(puppetlabsGH-225) Document functions in Puppet Datatypes
Previously the puppet datatype handler only documented attributes, not functions for example [1]. This commit updates the data type handler to read in the function information and then allow that to be used by puppet-strings in its JSON, Markdown and HTML renderers. This commit also adds tests for many different scenarios and all three rendering types. [1] https://github.com/puppetlabs/puppet/blob/3e03e734dda415272ec156b03ed9f021ba243228/lib/puppet/datatypes/error.rb#L13-L15
- Loading branch information
1 parent
cee0da1
commit 1900b26
Showing
13 changed files
with
689 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
lib/puppet-strings/markdown/templates/data_type_function.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
### <%= name %> | ||
|
||
#### `<%= signature %>` | ||
|
||
<% if text -%> | ||
<%= text %> | ||
<% elsif summary -%> | ||
<%= summary %> | ||
<% else -%> | ||
<%= "The #{name} function." %> | ||
<% end -%> | ||
<% if note -%> | ||
* **Note** <%= note %> | ||
<% end -%> | ||
<% if return_type -%> | ||
Returns: `<%= return_type %>`<% if return_val %> <%= return_val %><% end %> | ||
<% end -%> | ||
<% if raises -%> | ||
Raises: | ||
<% raises.each do |r| -%> | ||
* <%= error_type(r[:text]) %> <%= error_text(r[:text]) %> | ||
<% end -%> | ||
<% end -%> | ||
<% if examples -%> | ||
##### Examples | ||
|
||
<% examples.each do |eg| -%> | ||
###### <%= eg[:name] %> | ||
|
||
```puppet | ||
<%= eg[:text] %> | ||
``` | ||
|
||
<% end -%> | ||
<% end -%> | ||
<% if params -%> | ||
<% params.each do |param| -%> | ||
##### `<%= param[:name] %>` | ||
|
||
Data type: `<%= param[:types][0] %>` | ||
|
||
<%= param[:text] %> | ||
<% if options_for_param(param[:name]) -%> | ||
Options: | ||
|
||
<% options_for_param(param[:name]).each do |o| -%> | ||
* **<%= o[:opt_name] %>** `<%= o[:opt_types][0] %>`: <%= o[:opt_text] %> | ||
<% end -%> | ||
<% end -%> | ||
<% if enums_for_param(param[:name]) -%> | ||
Options: | ||
|
||
<% enums_for_param(param[:name]).each do |e| -%> | ||
* **<%= e[:opt_name] %>**: <%= e[:opt_text] %> | ||
<% end -%> | ||
<% end -%> | ||
<% end -%> | ||
<% end -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.