Skip to content

Commit 4ea43e0

Browse files
committed
re-add test for Puppet 3 function
1 parent 49573ca commit 4ea43e0

4 files changed

Lines changed: 39 additions & 3 deletions

File tree

lib/puppet-strings/markdown/base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ def initialize(registry, component_type)
5858
{ :return_val => 'return',
5959
:since => 'since',
6060
:summary => 'summary' }.each do |method_name, tag_name|
61+
# @return [String] unless the tag is nil or the string.length == 0
6162
define_method method_name do
62-
@tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text] unless @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0].nil?
63+
@tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text] unless @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0].nil? || @tags.select { |tag| tag[:tag_name] == "#{tag_name}" }[0][:text].length.zero?
6364
end
6465
end
6566

lib/puppet-strings/markdown/templates/function.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ Type: <%= type %>
88
<%= sig.text %>
99

1010
<% end -%>
11-
<% if sig.return_val -%>
12-
Returns: `<%= sig.return_type %>` <%= sig.return_val %>
11+
<% if sig.return_type -%>
12+
Returns: `<%= sig.return_type %>`<% if sig.return_val %> <%= sig.return_val %><% end %>
1313

1414
<% end -%>
1515
<% if raises -%>

spec/fixtures/unit/markdown/output.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [`database`](#database): An example database server type.
1010
## Functions
1111
* [`func`](#func): A simple Puppet function.
12+
* [`func3x`](#func3x): Documentation for an example 3.x function.
1213
* [`func4x`](#func4x): An example 4.x function.
1314
* [`func4x_1`](#func4x_1): An example 4.x function with only one signature.
1415
## Classes
@@ -279,6 +280,27 @@ Options:
279280

280281
* **:param3opt** `Array`: Something about this option
281282

283+
### func3x
284+
Type: Ruby 3.x API
285+
286+
#### `func3x(String $param1, Integer $param2)`
287+
288+
Documentation for an example 3.x function.
289+
290+
Returns: `Undef`
291+
292+
##### `param1`
293+
294+
Data type: `String`
295+
296+
The first parameter.
297+
298+
##### `param2`
299+
300+
Data type: `Integer`
301+
302+
The second parameter.
303+
282304
### func4x
283305
Type: Ruby 4.x API
284306

spec/unit/puppet-strings/markdown_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,19 @@ class klass (
111111
end
112112
end
113113
114+
# An example 3.x function
115+
Puppet::Parser::Functions.newfunction(:func3x, doc: <<-DOC
116+
Documentation for an example 3.x function.
117+
@param param1 [String] The first parameter.
118+
@param param2 [Integer] The second parameter.
119+
@return [Undef]
120+
@example Calling the function.
121+
func3x('hi', 10)
122+
DOC
123+
) do |*args|
124+
#...
125+
end
126+
114127
Puppet::Type.type(:database).provide :linux do
115128
desc 'An example provider on Linux.'
116129
confine kernel: 'Linux'

0 commit comments

Comments
 (0)