puppet-lint-param-docs 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b74b2eba1bf2552829262b8cbbb7ec77de00457
4
- data.tar.gz: 072f70beee8e599b8b50e8a26aa9f848eb1faa9a
3
+ metadata.gz: 1cd697d0feb34c823acfdb9c02da8dc0c51e79e3
4
+ data.tar.gz: 208239c0f29443cd62bb57e6a1dd39e08baec929
5
5
  SHA512:
6
- metadata.gz: 368cea9c49874b060719f7663aba531515435777be4185112cc22dd0c767d9ca234f2533c0ac40d486f69947fecdcb9d01cc05a73ddb737a1c1eac96cb0bd84f
7
- data.tar.gz: d97334cb071b50f732b785b6b068e02fb486248149209d1e5fdcd82ddc14a7d2e47b4aae0c70f13fc7460868bef2c6bc1ba49e0d83967b945b548661e5a36d28
6
+ metadata.gz: a6009a3d8e57ecfa4979efc2e403a0c0392a9023f201e0bd1efe1cda86de02c9a6edd6c3bfec28dd010fe4e3e10ff94166d40cabd8b37f796ba23ece61b25f77
7
+ data.tar.gz: 7ded50a856ce0bd2c0e07e8c2b85172204bdb275592c8d5d06ff29280e24e9e56ea80a9cacf9bf0082fa906c51946eff2cad13e8f05314aef295f420d3fce7b5
data/README.md CHANGED
@@ -31,6 +31,45 @@ WARNING: missing documentation for class parameter foo::bar
31
31
  WARNING: missing documentation for defined type parameter foo::baz
32
32
  ```
33
33
 
34
+ ### Documentation styles
35
+
36
+ The check will accept any of the following styles:
37
+
38
+ #### Puppet Strings
39
+
40
+ Used by [Puppet Strings](https://github.com/puppetlabs/puppetlabs-strings).
41
+
42
+ # Example class
43
+ #
44
+ # @param foo example
45
+ define example($foo) { }
46
+
47
+ #### Puppet Doc style
48
+
49
+ Used by the [puppet-doc](https://docs.puppetlabs.com/puppet/latest/reference/man/doc.html)
50
+ command, generally deprecated in favour of Puppet Strings.
51
+
52
+ # Example class
53
+ #
54
+ # === Parameters:
55
+ #
56
+ # [*foo*] example
57
+ #
58
+ class example($foo) { }
59
+
60
+ #### Kafo rdoc style
61
+
62
+ Used in [kafo](https://github.com/theforeman/kafo#documentation) following an
63
+ rdoc style.
64
+
65
+ # Example class
66
+ #
67
+ # === Parameters:
68
+ #
69
+ # $foo:: example
70
+ #
71
+ class example($foo) { }
72
+
34
73
  ### Selective rake task
35
74
 
36
75
  The usual puppet-lint rake task checks all manifests, which isn't always
@@ -39,10 +78,10 @@ some of which you don't wish to document, then you can exclude them using
39
78
  [control comments](http://puppet-lint.com/controlcomments/) or by using this
40
79
  helper to customise the lint rake task:
41
80
 
42
- require 'puppet-lint-param-docs/tasks'
43
- PuppetLintParamDocs.define_selective do |config|
44
- config.pattern = ['manifests/init.pp', 'manifests/other/**/*.pp']
45
- end
81
+ require 'puppet-lint-param-docs/tasks'
82
+ PuppetLintParamDocs.define_selective do |config|
83
+ config.pattern = ['manifests/init.pp', 'manifests/other/**/*.pp']
84
+ end
46
85
 
47
86
  This would disable the parameter_documentation check by default, but then
48
87
  defines a new rake task (which runs after `lint`) specifically for the files
@@ -8,7 +8,8 @@ PuppetLint.new_check(:parameter_documentation) do
8
8
  next if [:CLASS, :DEFINE, :NEWLINE, :WHITESPACE, :INDENT].include?(dtok.type)
9
9
  if [:COMMENT, :MLCOMMENT, :SLASH_COMMENT].include?(dtok.type)
10
10
  if dtok.value =~ /\A\s*\[\*([a-zA-Z0-9_]+)\*\]/ or
11
- dtok.value =~ /\A\s*\$([a-zA-Z0-9_]+):: +/
11
+ dtok.value =~ /\A\s*\$([a-zA-Z0-9_]+):: +/ or
12
+ dtok.value =~ /\A\s*@param ([a-zA-Z0-9_]+) +/
12
13
  doc_params << $1
13
14
  end
14
15
  else
@@ -130,6 +130,44 @@ define foreman (
130
130
  end
131
131
  end
132
132
 
133
+ context 'class missing documentation (@param bar) for a parameter' do
134
+ let(:code) do
135
+ <<-EOS.gsub(/^\s+/, '')
136
+ # Example class
137
+ #
138
+ # @param bar example
139
+ class example($foo, $bar) { }
140
+ EOS
141
+ end
142
+
143
+ it 'should detect a single problem' do
144
+ expect(problems).to have(1).problem
145
+ end
146
+
147
+ it 'should create a warning' do
148
+ expect(problems).to contain_warning(class_msg % :foo).on_line(4).in_column(15)
149
+ end
150
+ end
151
+
152
+ context 'define missing documentation (@param bar) for a parameter' do
153
+ let(:code) do
154
+ <<-EOS.gsub(/^\s+/, '')
155
+ # Example class
156
+ #
157
+ # @param bar example
158
+ define example($foo, $bar) { }
159
+ EOS
160
+ end
161
+
162
+ it 'should detect a single problem' do
163
+ expect(problems).to have(1).problem
164
+ end
165
+
166
+ it 'should create a warning' do
167
+ expect(problems).to contain_warning(define_msg % :foo).on_line(4).in_column(16)
168
+ end
169
+ end
170
+
133
171
  context 'class missing documentation ([*bar*]) for a parameter' do
134
172
  let(:code) do
135
173
  <<-EOS.gsub(/^\s+/, '')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppet-lint-param-docs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dominic Cleal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puppet-lint