File: functions_template.erb

package info (click to toggle)
puppet-agent 8.10.0-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 27,392 kB
  • sloc: ruby: 286,820; sh: 492; xml: 116; makefile: 88; cs: 68
file content (47 lines) | stat: -rw-r--r-- 1,491 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<% functions.sort{|a,b| a['name'] <=> b['name'] }.each do |func| -%>
## `<%= func['name'] %>`

<%= func['docstring']['text'] %>

<% func_signatures = func['signatures']
multiple_signatures = func_signatures.count > 1
if func_signatures
func['signatures'].each_with_index do |signature, index| -%>

<% if multiple_signatures -%>
Signature <%= index+1 %>

<% end -%>
`<%= signature['signature'] %>`
<% has_parameters = signature.dig('docstring', 'tags')&.detect {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil } || false
if has_parameters -%>

### Parameters

<% signature['docstring']['tags'].select {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil}.each do |param| -%>

* `<%= param['name'] %>` --- <%= param['text'] %>
<% end # each param

return_types = signature['docstring']['tags'].detect {|tag| tag['tag_name'] == 'return'}
if return_types -%>

Return type(s): <%= return_types['types'].map {|t| "`#{t}`"}.join(', ') %>. <%= return_types['text'] %>
<% end # if return_types
has_examples = signature['docstring']['tags'].detect {|tag| tag['tag_name'] == 'example' && tag['text'] != '' && tag['text'] != nil }
if has_examples %>

### Examples

<% signature['docstring']['tags'].select {|tag| tag['tag_name'] == 'example' && tag['text'] != '' && tag['text'] != nil}.each do |example| -%>
<%= example['name'] %>

<%= example['text'] %>

<% end # each example
end # if has_examples
end-%>
<% end # each signature
end -%>

<% end -%>