Skip to content

Commit 8242136

Browse files
authored
Merge pull request #1239 from puppetlabs/unbreak-rake-reference
Unbreak `rake strings:generate:reference`
2 parents 2592c83 + c6287f0 commit 8242136

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+787
-283
lines changed

REFERENCE.md

Lines changed: 663 additions & 169 deletions
Large diffs are not rendered by default.

functions/ensure.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# @summary function to cast ensure parameter to resource specific value
2+
#
3+
# @return [String]
24
function stdlib::ensure(
35
Variant[Boolean, Enum['present', 'absent']] $ensure,
46
Enum['directory', 'link', 'mounted', 'service', 'file', 'package'] $resource,

lib/puppet/functions/parsehocon.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,13 @@
44
# This function accepts HOCON as a string and converts it into the correct
55
# Puppet structure
66
#
7-
# @return
8-
# Data
9-
#
107
# @example How to parse hocon
118
# $data = parsehocon("{any valid hocon: string}")
129
#
1310
Puppet::Functions.create_function(:parsehocon) do
1411
# @param hocon_string A valid HOCON string
1512
# @param default An optional default to return if parsing hocon_string fails
13+
# @return [Data]
1614
dispatch :parsehocon do
1715
param 'String', :hocon_string
1816
optional_param 'Any', :default

lib/puppet/functions/stdlib/str2resource.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
# @summary
44
# This converts a string to a puppet resource.
55
#
6-
# This attempts to convert a string like 'File[/foo]' into the
7-
# puppet resource `File['/foo']` as detected by the catalog.
6+
# This attempts to convert a string like 'File[/foo]' into the
7+
# puppet resource `File['/foo']` as detected by the catalog.
88
#
9-
# Things like 'File[/foo, /bar]' are not supported as a
10-
# title might contain things like ',' or ' '. There is
11-
# no clear value seperator to use.
9+
# Things like 'File[/foo, /bar]' are not supported as a
10+
# title might contain things like ',' or ' '. There is
11+
# no clear value seperator to use.
1212
#
13-
# This function can depend on the parse order of your
14-
# manifests/modules as it inspects the catalog thus far.
13+
# This function can depend on the parse order of your
14+
# manifests/modules as it inspects the catalog thus far.
1515
Puppet::Functions.create_function(:'stdlib::str2resource') do
1616
# @param res_string The string to lookup as a resource
1717
# @example

lib/puppet/functions/to_json.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
require 'json'
44
# @summary
55
# Convert a data structure and output to JSON
6-
#
7-
# @example Output JSON to a file
8-
# file { '/tmp/my.json':
9-
# ensure => file,
10-
# content => to_json($myhash),
11-
# }
12-
#
136
Puppet::Functions.create_function(:to_json) do
147
# @param data
158
# Data structure which needs to be converted into JSON
9+
#
10+
# @example Output JSON to a file
11+
# file { '/tmp/my.json':
12+
# ensure => file,
13+
# content => to_json($myhash),
14+
# }
15+
#
1616
# @return [String] Converted data to JSON
1717
dispatch :to_json do
1818
param 'Any', :data

lib/puppet/functions/to_python.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
# }
1616

1717
Puppet::Functions.create_function(:to_python) do
18-
dispatch :to_python do
19-
param 'Any', :object
20-
end
21-
2218
# @param object
2319
# The object to be converted
2420
#
2521
# @return [String]
2622
# The String representation of the object
23+
dispatch :to_python do
24+
param 'Any', :object
25+
end
26+
2727
def to_python(object)
2828
serialized = Puppet::Pops::Serialization::ToDataConverter.convert(object, rich_data: true)
2929
serialized_to_python(serialized)

lib/puppet/functions/to_ruby.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
# }
1616

1717
Puppet::Functions.create_function(:to_ruby) do
18-
dispatch :to_ruby do
19-
param 'Any', :object
20-
end
21-
2218
# @param object
2319
# The object to be converted
2420
#
2521
# @return [String]
2622
# The String representation of the object
23+
dispatch :to_ruby do
24+
param 'Any', :object
25+
end
26+
2727
def to_ruby(object)
2828
serialized = Puppet::Pops::Serialization::ToDataConverter.convert(object, rich_data: true)
2929
serialized_to_ruby(serialized)

lib/puppet/functions/to_yaml.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@
33
require 'yaml'
44
# @summary
55
# Convert a data structure and output it as YAML
6-
#
7-
# @example Output YAML to a file
8-
# file { '/tmp/my.yaml':
9-
# ensure => file,
10-
# content => to_yaml($myhash),
11-
# }
12-
# @example Use options to control the output format
13-
# file { '/tmp/my.yaml':
14-
# ensure => file,
15-
# content => to_yaml($myhash, {indentation => 4})
16-
# }
176
Puppet::Functions.create_function(:to_yaml) do
187
# @param data
198
# The data you want to convert to YAML
209
# @param options
2110
# A hash of options that will be passed to Ruby's Psych library. Note, this could change between Puppet versions, but at time of writing these are `line_width`, `indentation`, and `canonical`.
2211
#
12+
# @example Output YAML to a file
13+
# file { '/tmp/my.yaml':
14+
# ensure => file,
15+
# content => to_yaml($myhash),
16+
# }
17+
# @example Use options to control the output format
18+
# file { '/tmp/my.yaml':
19+
# ensure => file,
20+
# content => to_yaml($myhash, {indentation => 4})
21+
# }
22+
#
2323
# @return [String] The YAML document
2424
dispatch :to_yaml do
2525
param 'Any', :data

lib/puppet/parser/functions/defined_with_params.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# Test whether a given class or definition is defined
44
require 'puppet/parser/functions'
55

6-
Puppet::Parser::Functions.newfunction(:defined_with_params,
7-
type: :rvalue,
8-
doc: <<-DOC,
6+
Puppet::Parser::Functions.newfunction(:defined_with_params, type: :rvalue, doc: <<-DOC
97
@summary
108
Takes a resource reference and an optional hash of attributes.
119
@@ -25,7 +23,7 @@
2523
@return [Boolean]
2624
returns `true` or `false`
2725
DOC
28-
) do |vals|
26+
) do |vals|
2927
reference, params = vals
3028
raise(ArgumentError, 'Must specify a reference') unless reference
3129
if !params || params == ''

lib/puppet/parser/functions/dig44.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
# dig44.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(
8-
:dig44,
9-
type: :rvalue,
10-
arity: -2,
11-
doc: <<-DOC,
7+
newfunction(:dig44, type: :rvalue, arity: -2, doc: <<-DOC
128
@summary
139
**DEPRECATED**: Looks up into a complex structure of arrays and hashes and returns a value
1410
or the default value if nothing was found.

lib/puppet/parser/functions/ensure_resource.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# Test whether a given class or definition is defined
44
require 'puppet/parser/functions'
55

6-
Puppet::Parser::Functions.newfunction(:ensure_resource,
7-
type: :statement,
8-
doc: <<-DOC,
6+
Puppet::Parser::Functions.newfunction(:ensure_resource, type: :statement, doc: <<-DOC
97
@summary
108
Takes a resource type, title, and a list of attributes that describe a
119
resource.
@@ -33,7 +31,7 @@
3331
ensure_resource('user', ['dan','alex'], {'ensure' => 'present'})
3432
3533
DOC
36-
) do |vals|
34+
) do |vals|
3735
type, title, params = vals
3836
raise(ArgumentError, 'Must specify a type') unless type
3937
raise(ArgumentError, 'Must specify a title') unless title

lib/puppet/parser/functions/ensure_resources.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22

33
require 'puppet/parser/functions'
44

5-
Puppet::Parser::Functions.newfunction(:ensure_resources,
6-
type: :statement,
7-
doc: <<-DOC,
5+
Puppet::Parser::Functions.newfunction(:ensure_resources, type: :statement, doc: <<-DOC
86
@summary
97
Takes a resource type, title (only hash), and a list of attributes that describe a
108
resource.
@@ -36,7 +34,7 @@
3634
Call:
3735
ensure_resources('user', hiera_hash('userlist'), {'ensure' => 'present'})
3836
DOC
39-
) do |vals|
37+
) do |vals|
4038
type, title, params = vals
4139
raise(ArgumentError, 'Must specify a type') unless type
4240
raise(ArgumentError, 'Must specify a title') unless title

lib/puppet/parser/functions/fqdn_rand_string.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# frozen_string_literal: true
22

3-
Puppet::Parser::Functions.newfunction(
4-
:fqdn_rand_string,
5-
arity: -2,
6-
type: :rvalue,
7-
doc: <<-DOC,
3+
Puppet::Parser::Functions.newfunction(:fqdn_rand_string, arity: -2, type: :rvalue, doc: <<-DOC
84
@summary
95
Generates a random alphanumeric string. Combining the `$fqdn` fact and an
106
optional seed for repeatable randomness.

lib/puppet/parser/functions/fqdn_rotate.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#
44
# fqdn_rotate.rb
55
#
6-
Puppet::Parser::Functions.newfunction(
7-
:fqdn_rotate,
8-
type: :rvalue,
9-
doc: <<-DOC,
6+
Puppet::Parser::Functions.newfunction(:fqdn_rotate, type: :rvalue, doc: <<-DOC
107
@summary
118
Rotates an array or string a random number of times, combining the `$fqdn` fact
129
and an optional seed for repeatable randomness.

lib/puppet/parser/functions/getparam.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
# Test whether a given class or definition is defined
44
require 'puppet/parser/functions'
55

6-
Puppet::Parser::Functions.newfunction(:getparam,
7-
type: :rvalue,
8-
doc: <<-'DOC',
6+
Puppet::Parser::Functions.newfunction(:getparam, type: :rvalue, doc: <<-'DOC'
97
@summary
108
Returns the value of a resource's parameter.
119
@@ -45,7 +43,7 @@
4543
```Example_resource['example_resource_instance']['param']``
4644
4745
DOC
48-
) do |vals|
46+
) do |vals|
4947
reference, param = vals
5048
raise(ArgumentError, 'Must specify a reference') unless reference
5149
raise(ArgumentError, 'Must specify name of a parameter') unless param&.instance_of?(String)

lib/puppet/parser/functions/pick.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
module Puppet::Parser::Functions
77
newfunction(:pick, type: :rvalue, doc: <<-EOS
88
@summary
9-
This function is similar to a coalesce function in SQL in that it will return
9+
This function will return
1010
the first value in a list of values that is not undefined or an empty string.
1111
12+
This function is similar to a coalesce function in SQL.
13+
1214
@return
1315
the first value in a list of values that is not undefined or an empty string.
1416

lib/puppet/parser/functions/pw_hash.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
# Please note: This function is an implementation of a Ruby class and as such may not be entirely UTF8 compatible.
44
# To ensure compatibility please use this function with Ruby 2.4.0 or greater - https://bugs.ruby-lang.org/issues/10085.
55
#
6-
Puppet::Parser::Functions.newfunction(
7-
:pw_hash,
8-
type: :rvalue,
9-
arity: 3,
10-
doc: <<-DOC,
6+
Puppet::Parser::Functions.newfunction(:pw_hash, type: :rvalue, arity: 3, doc: <<-DOC
117
@summary
128
Hashes a password using the crypt function. Provides a hash usable
139
on most POSIX systems.

lib/puppet/parser/functions/round.rb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ module Puppet::Parser::Functions
1111
@return
1212
the rounded value as integer
1313
14-
@example
15-
16-
```round(2.9)``` returns ```3```
17-
18-
```round(2.4)``` returns ```2```
14+
@example Example usage
15+
round(2.9) #=> 3
16+
round(2.4) #=> 2
1917
2018
> *Note:* from Puppet 6.0.0, the compatible function with the same name in Puppet core
2119
will be used instead of this function.

lib/puppet/parser/functions/seeded_rand.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
#
44
# seeded_rand.rb
55
#
6-
Puppet::Parser::Functions.newfunction(
7-
:seeded_rand,
8-
arity: 2,
9-
type: :rvalue,
10-
doc: <<-DOC,
6+
Puppet::Parser::Functions.newfunction(:seeded_rand, arity: 2, type: :rvalue, doc: <<-DOC
117
@summary
128
Generates a random whole number greater than or equal to 0 and less than MAX, using the value of SEED for repeatable randomness.
139

lib/puppet/parser/functions/try_get_value.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
# try_get_value.rb
55
#
66
module Puppet::Parser::Functions
7-
newfunction(
8-
:try_get_value,
9-
type: :rvalue,
10-
arity: -2,
11-
doc: <<-DOC,
7+
newfunction(:try_get_value, type: :rvalue, arity: -2, doc: <<-DOC
128
@summary
139
**DEPRECATED:** this function is deprecated, please use dig() instead.
1410

lib/puppet/parser/functions/validate_slength.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ module Puppet::Parser::Functions
77
newfunction(:validate_slength, doc: <<-DOC
88
@summary
99
Validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument.
10-
An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings,
11-
and if arg 2 and arg 3 are not convertable to a number.
10+
11+
An optional third parameter can be given the minimum length. It fails if the first argument is not a string or array of strings,
12+
and if arg 2 and arg 3 are not convertable to a number.
1213
1314
@return
1415
validate that the first argument is a string (or an array of strings), and less/equal to than the length of the second argument. Fail compilation if any of the checks fail.

lib/puppet/parser/functions/validate_x509_rsa_key_pair.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ module Puppet::Parser::Functions
77
newfunction(:validate_x509_rsa_key_pair, doc: <<-DOC
88
@summary
99
Validates a PEM-formatted X.509 certificate and RSA private key using
10-
OpenSSL. Verifies that the certficate's signature was created from the
11-
supplied key.
10+
OpenSSL.
11+
12+
Verifies that the certficate's signature was created from the
13+
supplied key.
1214
1315
@return
1416
Fail compilation if any value fails this check.

manifests/manage.pp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
# }
3131
#
3232
# @example
33-
# stdlib::manage::create_resources:
34-
# file:
35-
# '/etc/motd.d/hello':
36-
# content: I say Hi
37-
# notify: 'Service[sshd]'
38-
# package:
39-
# example:
40-
# ensure: installed
33+
# stdlib::manage::create_resources:
34+
# file:
35+
# '/etc/motd.d/hello':
36+
# content: I say Hi
37+
# notify: 'Service[sshd]'
38+
# package:
39+
# example:
40+
# ensure: installed
4141
class stdlib::manage (
4242
Hash[String, Hash] $create_resources = {}
4343
) {

types/absolutepath.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# A strict absolutepath type
1+
# @summary A strict absolutepath type
22
type Stdlib::Absolutepath = Variant[Stdlib::Windowspath, Stdlib::Unixpath]

types/base32.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Type to match base32 String
1+
# @summary Type to match base32 String
22
type Stdlib::Base32 = Pattern[/\A[a-z2-7]+={,6}\z/, /\A[A-Z2-7]+={,6}\z/]

types/base64.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Type to match base64 String
1+
# @summary Type to match base64 String
22
type Stdlib::Base64 = Pattern[/\A[a-zA-Z0-9\/\+]+={,2}\z/]

types/compat/absolute_path.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Emulate the is_absolute_path and validate_absolute_path functions
1+
# @summary Emulate the is_absolute_path and validate_absolute_path functions
22
#
33
# The first pattern is originally from is_absolute_path, which had it from 2.7.x's lib/puppet/util.rb Puppet::Util.absolute_path?
44
# slash = '[\\\\/]'

types/compat/array.pp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# Emulate the is_array and validate_array functions
1+
# @summary Emulate the is_array and validate_array functions
22
type Stdlib::Compat::Array = Array[Any]

0 commit comments

Comments
 (0)