puppet-doc-lint 0.0.1
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 +7 -0
- data/.gitignore +3 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +8 -0
- data/Gemfile +4 -0
- data/LICENSE +20 -0
- data/README.md +49 -0
- data/Rakefile +13 -0
- data/bin/puppet-doc-lint +20 -0
- data/lib/puppet-doc-lint.rb +25 -0
- data/lib/puppet-doc-lint/configuration.rb +170 -0
- data/lib/puppet-doc-lint/doc_runner.rb +34 -0
- data/lib/puppet-doc-lint/hash.rb +13 -0
- data/lib/puppet-doc-lint/parser.rb +61 -0
- data/lib/puppet-doc-lint/rake_task.rb +17 -0
- data/lib/puppet-doc-lint/result.rb +23 -0
- data/lib/puppet-doc-lint/runner.rb +34 -0
- data/lib/puppet-doc-lint/version.rb +3 -0
- data/puppet-doc-lint.gemspec +28 -0
- data/spec/manifests/define_nordoc.pp +8 -0
- data/spec/manifests/define_rdoc.pp +20 -0
- data/spec/manifests/noclass.pp +4 -0
- data/spec/manifests/noparameters_nordoc.pp +3 -0
- data/spec/manifests/noparameters_rdoc.pp +15 -0
- data/spec/manifests/parameters_nordoc.pp +8 -0
- data/spec/manifests/parameters_rdoc.pp +20 -0
- data/spec/runner_acceptance_spec.rb +131 -0
- data/spec/runner_results_spec.rb +37 -0
- data/spec/spec_helper.rb +20 -0
- metadata +173 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3869048bc78f3c9a1f104bcaf28111130e6d0511
|
4
|
+
data.tar.gz: aef6d72342b140b4b1444e08a80fc123eaeb7cb6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 622affc112e5377071b2a8ec6a2455ecbfa8626e8e98846e1ca2f8fef425156da38a51571d1cecb6d913e4fc23c2614d2302da13c36060ad11f92fe39b20d25f
|
7
|
+
data.tar.gz: 866228c5ebe8d5bb982cba81e2487b142b473657331f976e46d22ecfc431a0476c3b94037a34fa755180e78c21562e3ce8f219803e2cfd131e8153e6efcb5f08
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 0.0.1
|
4
|
+
|
5
|
+
Initial release
|
6
|
+
- Very messy implementation for now
|
7
|
+
- Outputs full list of parameters and highlights parameters that are undocumented.
|
8
|
+
- Initial code for a results class for cleaner output and allows users more nuanced data, but not working properly yet!
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Peter Souter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# puppet-doc-lint
|
2
|
+
|
3
|
+
Lint your Puppet files for RDoc coverage
|
4
|
+
|
5
|
+
This project is heavily based on the puppet-parse code base, go check it out! :smile:
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
gem install puppet-doc-lint
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
### By hand
|
15
|
+
|
16
|
+
You can report on one or more manifests by running
|
17
|
+
|
18
|
+
puppet-doc-lint <path(s) to file(s)>
|
19
|
+
|
20
|
+
For example:
|
21
|
+
|
22
|
+
```
|
23
|
+
puppet-doc-lint ~/Projects/puppetlabs-firewall/manifests/linux/debian.pp
|
24
|
+
class firewall::linux::debian Parameters are ["ensure", "enable"]
|
25
|
+
class firewall::linux::debian Docs found are ["ensure", "enable"]
|
26
|
+
```
|
27
|
+
|
28
|
+
### Rake task
|
29
|
+
|
30
|
+
If you want to parse your entire modules directory, you can add
|
31
|
+
`require 'puppet-doc-lint/rake-task' to your Rakefile and then run
|
32
|
+
|
33
|
+
rake parse
|
34
|
+
|
35
|
+
If you need to ignore certain paths from being parsed:
|
36
|
+
|
37
|
+
``` ruby
|
38
|
+
PuppetDocLint.configuration.ignore_paths = ["vendor/**/*.pp"]
|
39
|
+
```
|
40
|
+
|
41
|
+
## Contributing
|
42
|
+
|
43
|
+
You can do any of these:
|
44
|
+
|
45
|
+
1. Create new Pull Request
|
46
|
+
2. Create an issue
|
47
|
+
3. Write me an email
|
48
|
+
4. Complain about how useless my code is on twitter
|
49
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
require 'rake'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'puppet-doc-lint/rake_task'
|
7
|
+
|
8
|
+
Bundler.setup
|
9
|
+
Bundler::GemHelper.install_tasks
|
10
|
+
|
11
|
+
task :default => :spec
|
12
|
+
|
13
|
+
RSpec::Core::RakeTask.new(:spec)
|
data/bin/puppet-doc-lint
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'puppet-doc-lint'
|
4
|
+
|
5
|
+
abort 'puppet-doc-lint: no arguments given ' if ARGV[0].nil?
|
6
|
+
|
7
|
+
runner = PuppetDocLint::Runner.new
|
8
|
+
|
9
|
+
path = ARGV[0]
|
10
|
+
if File.directory?(path)
|
11
|
+
puppet_files = Dir.glob("#{path}/**/*.pp")
|
12
|
+
puts "Puppet docs to be checked: #{puppet_files}"
|
13
|
+
results = runner.run(puppet_files)
|
14
|
+
else
|
15
|
+
results = runner.run(ARGV)
|
16
|
+
end
|
17
|
+
|
18
|
+
results.each do |result|
|
19
|
+
result.result_report
|
20
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'puppet'
|
2
|
+
require 'puppet-doc-lint/version'
|
3
|
+
require 'puppet-doc-lint/parser'
|
4
|
+
require 'puppet-doc-lint/runner'
|
5
|
+
require 'puppet-doc-lint/doc_runner'
|
6
|
+
require 'puppet-doc-lint/result'
|
7
|
+
require 'puppet-doc-lint/hash'
|
8
|
+
require 'puppet-doc-lint/configuration'
|
9
|
+
require 'rdoc'
|
10
|
+
|
11
|
+
class PuppetDocLint
|
12
|
+
# Public: Access PuppetDocLint's configuration from outside the class.
|
13
|
+
#
|
14
|
+
# Returns a PuppetDocLint::Configuration object.
|
15
|
+
def self.configuration
|
16
|
+
@configuration ||= PuppetDocLint::Configuration.new
|
17
|
+
end
|
18
|
+
|
19
|
+
# Public: Access PuppetDocLint's configuration from inside the class.
|
20
|
+
#
|
21
|
+
# Returns a PuppetDocLint::Configuration object.
|
22
|
+
def configuration
|
23
|
+
self.class.configuration
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,170 @@
|
|
1
|
+
class PuppetDocLint
|
2
|
+
class Configuration
|
3
|
+
|
4
|
+
# Code blatently stolen from https://github.com/rodjek/puppet-lint
|
5
|
+
|
6
|
+
# Internal: Add helper methods for a new check to the
|
7
|
+
# PuppetDocLint::Configuration object.
|
8
|
+
#
|
9
|
+
# check - The String name of the check.
|
10
|
+
#
|
11
|
+
# Returns nothing.
|
12
|
+
#
|
13
|
+
# Signature
|
14
|
+
#
|
15
|
+
# <check>_enabled?
|
16
|
+
# disable_<check>
|
17
|
+
# enable_<check>
|
18
|
+
def self.add_check(check)
|
19
|
+
# Public: Determine if the named check is enabled.
|
20
|
+
#
|
21
|
+
# Returns true if the check is enabled, otherwise return false.
|
22
|
+
define_method("#{check}_enabled?") do
|
23
|
+
settings["#{check}_disabled"] == true ? false : true
|
24
|
+
end
|
25
|
+
|
26
|
+
# Public: Disable the named check.
|
27
|
+
#
|
28
|
+
# Returns nothing.
|
29
|
+
define_method("disable_#{check}") do
|
30
|
+
settings["#{check}_disabled"] = true
|
31
|
+
end
|
32
|
+
|
33
|
+
# Public: Enable the named check.
|
34
|
+
#
|
35
|
+
# Returns nothing.
|
36
|
+
define_method("enable_#{check}") do
|
37
|
+
settings["#{check}_disabled"] = false
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# Public: Catch situations where options are being set for the first time
|
42
|
+
# and create the necessary methods to get & set the option in the future.
|
43
|
+
#
|
44
|
+
# args[0] - The value to set the option to.
|
45
|
+
#
|
46
|
+
# Returns nothing.
|
47
|
+
#
|
48
|
+
# Signature
|
49
|
+
#
|
50
|
+
# <option>=(value)
|
51
|
+
def method_missing(method, *args, &block)
|
52
|
+
if method.to_s =~ /^(\w+)=$/
|
53
|
+
option = $1
|
54
|
+
add_option(option.to_s) if settings[option].nil?
|
55
|
+
settings[option] = args[0]
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# Internal: Add options to the PuppetDocLint::Configuration object from inside
|
62
|
+
# the class.
|
63
|
+
#
|
64
|
+
# option - The String name of the option.
|
65
|
+
#
|
66
|
+
# Returns nothing.
|
67
|
+
#
|
68
|
+
# Signature
|
69
|
+
#
|
70
|
+
# <option>
|
71
|
+
# <option>=(value)
|
72
|
+
def add_option(option)
|
73
|
+
self.class.add_option(option)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Public: Add an option to the PuppetDocLint::Configuration object from
|
77
|
+
# outside the class.
|
78
|
+
#
|
79
|
+
# option - The String name of the option.
|
80
|
+
#
|
81
|
+
# Returns nothing.
|
82
|
+
#
|
83
|
+
# Signature
|
84
|
+
#
|
85
|
+
# <option>
|
86
|
+
# <option>=(value)
|
87
|
+
def self.add_option(option)
|
88
|
+
# Public: Set the value of the named option.
|
89
|
+
#
|
90
|
+
# value - The value to set the option to.
|
91
|
+
#
|
92
|
+
# Returns nothing.
|
93
|
+
define_method("#{option}=") do |value|
|
94
|
+
settings[option] = value
|
95
|
+
end
|
96
|
+
|
97
|
+
# Public: Get the value of the named option.
|
98
|
+
#
|
99
|
+
# Returns the value of the option.
|
100
|
+
define_method(option) do
|
101
|
+
settings[option]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
# Internal: Register a new check.
|
106
|
+
#
|
107
|
+
# check - The String name of the check
|
108
|
+
# b - The Block containing the logic of the check
|
109
|
+
#
|
110
|
+
# Returns nothing.
|
111
|
+
def add_check(check, &b)
|
112
|
+
self.class.add_check(check)
|
113
|
+
check_method[check] = b
|
114
|
+
end
|
115
|
+
|
116
|
+
# Internal: Register a new check helper method.
|
117
|
+
#
|
118
|
+
# name - The String name of the method.
|
119
|
+
# b - The Block containing the logic of the helper.
|
120
|
+
#
|
121
|
+
# Returns nothing.
|
122
|
+
def add_helper(name, &b)
|
123
|
+
helper_method[name] = b
|
124
|
+
end
|
125
|
+
|
126
|
+
# Internal: Access the internal storage for settings.
|
127
|
+
#
|
128
|
+
# Returns a Hash containing all the settings.
|
129
|
+
def settings
|
130
|
+
@settings ||= {}
|
131
|
+
end
|
132
|
+
|
133
|
+
# Internal: Access the internal storage for check method blocks.
|
134
|
+
#
|
135
|
+
# Returns a Hash containing all the check blocks.
|
136
|
+
def check_method
|
137
|
+
@check_method ||= {}
|
138
|
+
end
|
139
|
+
|
140
|
+
# Public: Get a list of all the defined checks.
|
141
|
+
#
|
142
|
+
# Returns an Array of String check names.
|
143
|
+
def checks
|
144
|
+
check_method.keys
|
145
|
+
end
|
146
|
+
|
147
|
+
# Internal: Access the internal storage for helper method blocks.
|
148
|
+
#
|
149
|
+
# Returns a Hash containing all the helper blocks.
|
150
|
+
def helper_method
|
151
|
+
@helper_method ||= {}
|
152
|
+
end
|
153
|
+
|
154
|
+
# Public: Get a list of all the helper methods.
|
155
|
+
#
|
156
|
+
# Returns an Array of String method names.
|
157
|
+
def helpers
|
158
|
+
helper_method.keys
|
159
|
+
end
|
160
|
+
|
161
|
+
# Public: Clear the PuppetDocLint::Configuration storage and set some sane
|
162
|
+
# default values.
|
163
|
+
#
|
164
|
+
# Returns nothing.
|
165
|
+
def defaults
|
166
|
+
settings.clear
|
167
|
+
end
|
168
|
+
|
169
|
+
end # class Configuration
|
170
|
+
end # module PuppetDocLint
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class PuppetDocLint
|
2
|
+
class DocRunner
|
3
|
+
def initialize
|
4
|
+
end
|
5
|
+
|
6
|
+
def run(files)
|
7
|
+
runner_results = []
|
8
|
+
files.each do |file|
|
9
|
+
puppet_file_result = Result.new
|
10
|
+
Puppet.initialize_settings unless Puppet.settings.app_defaults_initialized?
|
11
|
+
content = PuppetDocLint::Parser.new(file)
|
12
|
+
next if content.instance_variable_get('@object').nil?
|
13
|
+
parameters = (defined? content.parameters) ? content.parameters.paramflat : nil
|
14
|
+
puppet_file_result.class_name = content.klass
|
15
|
+
puppet_file_result.no_documentation = true if content.docs == {}
|
16
|
+
result = {
|
17
|
+
content.klass => {
|
18
|
+
'parameters' => parameters,
|
19
|
+
'docs' => content.docs
|
20
|
+
}
|
21
|
+
}
|
22
|
+
puppet_file_result.parameters = parameters.keys
|
23
|
+
undocumented = parameters.keys - content.docs.keys
|
24
|
+
puppet_file_result.undocumented_parameters = undocumented unless undocumented.empty?
|
25
|
+
documented = parameters.keys - undocumented
|
26
|
+
puppet_file_result.documented_parameters = documented unless undocumented.empty?
|
27
|
+
runner_results << puppet_file_result
|
28
|
+
end
|
29
|
+
runner_results
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end #class Runner
|
34
|
+
end #module PuppetDocLint
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class PuppetDocLint
|
2
|
+
class Parser
|
3
|
+
|
4
|
+
def initialize(file)
|
5
|
+
# Read file and return parsed object
|
6
|
+
pparser = Puppet::Parser::Parser.new('production')
|
7
|
+
if File.exists?(file)
|
8
|
+
@file = File.expand_path(file)
|
9
|
+
pparser.import(@file)
|
10
|
+
|
11
|
+
# Find object in list of hostclasses
|
12
|
+
pparser.environment.known_resource_types.hostclasses.each do |x|
|
13
|
+
@object = x.last if x.last.file == @file
|
14
|
+
end
|
15
|
+
# Find object in list of definitions
|
16
|
+
pparser.environment.known_resource_types.definitions.each do |x|
|
17
|
+
@object = x.last if x.last.file == @file
|
18
|
+
end
|
19
|
+
|
20
|
+
else
|
21
|
+
'File does not exist'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Read parameters from parsed object, returns hash of parameters and default
|
26
|
+
# values
|
27
|
+
def parameters
|
28
|
+
result = (defined? @object.arguments) ? @object.arguments : {}
|
29
|
+
result
|
30
|
+
end
|
31
|
+
|
32
|
+
# Read class from parsed object, returns string containing class
|
33
|
+
def klass
|
34
|
+
@object.name if (defined? @object.class.name)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Read RDOC contents from parsed object, returns hash of paragraph headings
|
38
|
+
# and the following paragraph contents
|
39
|
+
#(i.e. parameter and parameter documentation)
|
40
|
+
def docs
|
41
|
+
if !@object.doc.nil?
|
42
|
+
rdoc = RDoc::Markup.parse(@object.doc)
|
43
|
+
docs = {}
|
44
|
+
|
45
|
+
rdoc.parts.each do |part|
|
46
|
+
if part.respond_to?(:items)
|
47
|
+
part.items.each do |item|
|
48
|
+
# Skip rdoc items that aren't paragraphs
|
49
|
+
next unless (item.parts.to_s.scan("RDoc::Markup::Paragraph") == ["RDoc::Markup::Paragraph"])
|
50
|
+
# Documentation must be a list - if there's no label then skip
|
51
|
+
next if item.label.nil?
|
52
|
+
key = item.label.tr('^A-Za-z0-9_-', '')
|
53
|
+
docs[key] = item.parts.first.parts
|
54
|
+
end # do item
|
55
|
+
end # endif
|
56
|
+
end # do parm
|
57
|
+
docs
|
58
|
+
end # if nil?
|
59
|
+
end # def docs
|
60
|
+
end # class Parser
|
61
|
+
end # module PuppetDocLint
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'puppet-doc-lint'
|
2
|
+
require 'rake'
|
3
|
+
require 'rake/tasklib'
|
4
|
+
|
5
|
+
desc 'Run puppet-doc-lint'
|
6
|
+
task :parse_doc do
|
7
|
+
matched_files = FileList['**/*.pp']
|
8
|
+
|
9
|
+
if ignore_paths = PuppetDocLint.configuration.ignore_paths
|
10
|
+
matched_files = matched_files.exclude(*ignore_paths)
|
11
|
+
end
|
12
|
+
|
13
|
+
runner = PuppetDocLint::Runner.new
|
14
|
+
results = runner.run(matched_files)
|
15
|
+
|
16
|
+
results.each {|result| result.result_report}
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'virtus'
|
2
|
+
|
3
|
+
class PuppetDocLint
|
4
|
+
class Result
|
5
|
+
include Virtus.model
|
6
|
+
attribute :class_name, String
|
7
|
+
attribute :file_name, String
|
8
|
+
attribute :parameters, String
|
9
|
+
attribute :no_documentation, Boolean, :default => false
|
10
|
+
attribute :documented_parameters, String, :default => []
|
11
|
+
attribute :undocumented_parameters, String, :default => []
|
12
|
+
|
13
|
+
def result_report
|
14
|
+
puts "Class name was: #{class_name}"
|
15
|
+
puts "File name #{file_name}"
|
16
|
+
puts "Parameters found #{parameters}"
|
17
|
+
puts "No documentation error: #{no_documentation}"
|
18
|
+
puts "Documented parameters found: #{documented_parameters}"
|
19
|
+
puts "Undocumented parameters found: #{undocumented_parameters}\n\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
end #class Result
|
23
|
+
end #module PuppetDocLint
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class PuppetDocLint
|
2
|
+
class Runner
|
3
|
+
def run(files)
|
4
|
+
runner_results = []
|
5
|
+
files.each do |file|
|
6
|
+
puppet_file_result = Result.new
|
7
|
+
Puppet.initialize_settings unless Puppet.settings.app_defaults_initialized?
|
8
|
+
content = PuppetDocLint::Parser.new(file)
|
9
|
+
next if content.instance_variable_get('@object').nil?
|
10
|
+
parameters = (defined? content.parameters) ? content.parameters.paramflat : nil
|
11
|
+
puppet_file_result.class_name = content.klass
|
12
|
+
puppet_file_result.no_documentation = true if content.docs == {}
|
13
|
+
result = {
|
14
|
+
content.klass => {
|
15
|
+
'parameters' => parameters,
|
16
|
+
'docs' => content.docs
|
17
|
+
}
|
18
|
+
}
|
19
|
+
puppet_file_result.file_name = file
|
20
|
+
puppet_file_result.parameters = parameters.keys
|
21
|
+
|
22
|
+
undocumented = parameters.keys - content.docs.keys
|
23
|
+
documented = parameters.keys - undocumented
|
24
|
+
|
25
|
+
puppet_file_result.documented_parameters = documented unless documented.empty?
|
26
|
+
puppet_file_result.undocumented_parameters = undocumented unless undocumented.empty?
|
27
|
+
|
28
|
+
runner_results << puppet_file_result
|
29
|
+
end
|
30
|
+
runner_results
|
31
|
+
end
|
32
|
+
|
33
|
+
end #class DocRunner
|
34
|
+
end #module PuppetDocLint
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/puppet-doc-lint/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Peter Souter"]
|
6
|
+
gem.email = ["p.morsou@gmail.com"]
|
7
|
+
gem.description = %q{Doc Parser for Puppet Modules. Returns Information about documentation.}
|
8
|
+
gem.summary = %q{Doc Parser for Puppet Modules. Returns Information about documentation.}
|
9
|
+
gem.homepage = "https://github.com/petems/puppet-doc-lint"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "puppet-doc-lint"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = PuppetDocLint::PUPPETDOCLINT_VERSION
|
17
|
+
|
18
|
+
gem.required_ruby_version = '>= 1.9.2'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec', '~> 2.14.1'
|
21
|
+
gem.add_development_dependency 'rake', '~> 10.1.1'
|
22
|
+
gem.add_runtime_dependency 'rdoc', '>=3.12', '<4.0'
|
23
|
+
gem.add_runtime_dependency 'facter', '~> 1.6'
|
24
|
+
gem.add_runtime_dependency 'puppet', '~> 3.4.2'
|
25
|
+
gem.add_runtime_dependency 'virtus', '~> 1.0.1'
|
26
|
+
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# = Define: define_rdoc
|
2
|
+
#
|
3
|
+
# A define for testing puppet-doc-lint
|
4
|
+
#
|
5
|
+
# == Requirements
|
6
|
+
#
|
7
|
+
# None
|
8
|
+
#
|
9
|
+
# == Parameters
|
10
|
+
#
|
11
|
+
# [*param_one*]
|
12
|
+
# Param1 documentation text
|
13
|
+
define define_rdoc (
|
14
|
+
$param_one = true,
|
15
|
+
$param_two = '',
|
16
|
+
$param_three = $::fqdn,
|
17
|
+
$param_four
|
18
|
+
) {
|
19
|
+
# no content
|
20
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# = Class: parameters_rdoc
|
2
|
+
#
|
3
|
+
# A class for testing puppet-doc-lint
|
4
|
+
#
|
5
|
+
# == Requirements
|
6
|
+
#
|
7
|
+
# None
|
8
|
+
#
|
9
|
+
# == Parameters
|
10
|
+
#
|
11
|
+
# [*param_one*]
|
12
|
+
# Param1 documentation text
|
13
|
+
class parameters_rdoc (
|
14
|
+
$param_one = true,
|
15
|
+
$param_two = '',
|
16
|
+
$param_three = $::fqdn,
|
17
|
+
$param_four
|
18
|
+
) {
|
19
|
+
# no content
|
20
|
+
}
|
@@ -0,0 +1,131 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PuppetDocLint::DocRunner do
|
4
|
+
shared_examples "standard tests" do | file, klass |
|
5
|
+
subject { setup(file) }
|
6
|
+
|
7
|
+
it "result should be an array of PuppetDocLint::Result for #{file}" do
|
8
|
+
subject.class.should be(Array)
|
9
|
+
subject.first.class.should be(PuppetDocLint::Result)
|
10
|
+
end
|
11
|
+
|
12
|
+
it "file name should be defined for #{file}" do
|
13
|
+
subject.first.file_name.should eql file
|
14
|
+
end
|
15
|
+
|
16
|
+
it "class should be define_rdoc for #{file}" do
|
17
|
+
subject.first.class_name.should eql klass
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
shared_examples "parameters" do |file, klass|
|
23
|
+
subject { setup(file) }
|
24
|
+
it "parameters should have 4 elements #{file}" do
|
25
|
+
subject.first.parameters.count.should eql 4
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
shared_examples "no parameters" do |file, klass|
|
30
|
+
subject { setup(file) }
|
31
|
+
it "parameters should have 0 elements #{file}" do
|
32
|
+
subject.first.parameters.count.should eql 0
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
shared_examples "rdoc" do |file, klass|
|
37
|
+
subject { setup(file) }
|
38
|
+
it "no_documentation should be false #{file}" do
|
39
|
+
subject.first.no_documentation.should be_false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
shared_examples "no rdoc" do |file, klass|
|
44
|
+
subject { setup(file) }
|
45
|
+
it "no_documentation should be true #{file}" do
|
46
|
+
subject.first.class_name.should eql klass
|
47
|
+
subject.first.no_documentation.should be_true
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
shared_examples "nothing undocumented" do |file, klass|
|
52
|
+
subject { setup(file) }
|
53
|
+
it "no_documentation should be true #{file}" do
|
54
|
+
subject.first.class_name.should eql klass
|
55
|
+
subject.first.documented_parameters.should_not eql []
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
shared_examples "something undocumented" do |file, klass|
|
60
|
+
subject { setup(file) }
|
61
|
+
it "no_documentation should be true for #{file}" do
|
62
|
+
subject.first.class_name.should eql klass
|
63
|
+
subject.first.documented_parameters.should eql []
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe "run on an directory" do
|
68
|
+
puppet_files = Dir.glob('spec/manifests/**/*.pp')
|
69
|
+
subject { setup_folder(puppet_files) }
|
70
|
+
|
71
|
+
it "should return a multi-element array" do
|
72
|
+
subject.class.should be(Array)
|
73
|
+
subject.size.should eql(6)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "manifest with parameters and rdoc" do
|
79
|
+
file = 'spec/manifests/parameters_rdoc.pp'
|
80
|
+
klass = 'parameters_rdoc'
|
81
|
+
it_should_behave_like "standard tests", file, klass
|
82
|
+
it_should_behave_like "parameters", file, klass
|
83
|
+
it_should_behave_like "rdoc", file, klass
|
84
|
+
it_should_behave_like "nothing undocumented", file, klass
|
85
|
+
end
|
86
|
+
|
87
|
+
describe "manifest with parameters and no rdoc" do
|
88
|
+
file = 'spec/manifests/parameters_nordoc.pp'
|
89
|
+
klass = 'parameters_nordoc'
|
90
|
+
it_should_behave_like "standard tests", file, klass
|
91
|
+
it_should_behave_like "parameters", file, klass
|
92
|
+
it_should_behave_like "no rdoc", file, klass
|
93
|
+
it_should_behave_like "something undocumented", file, klass
|
94
|
+
end
|
95
|
+
|
96
|
+
describe "manifest with no parameters and rdoc" do
|
97
|
+
file = 'spec/manifests/noparameters_rdoc.pp'
|
98
|
+
klass = 'noparameters_rdoc'
|
99
|
+
it_should_behave_like "standard tests", file, klass
|
100
|
+
it_should_behave_like "no parameters", file, klass
|
101
|
+
it_should_behave_like "rdoc", file, klass
|
102
|
+
it_should_behave_like "something undocumented", file, klass
|
103
|
+
end
|
104
|
+
|
105
|
+
describe "manifest with no parameters and no rdoc" do
|
106
|
+
file = 'spec/manifests/noparameters_nordoc.pp'
|
107
|
+
klass = 'noparameters_nordoc'
|
108
|
+
it_should_behave_like "standard tests", file, klass
|
109
|
+
it_should_behave_like "no parameters", file, klass
|
110
|
+
it_should_behave_like "no rdoc", file, klass
|
111
|
+
it_should_behave_like "something undocumented", file, klass
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "define with rdoc" do
|
115
|
+
file = 'spec/manifests/define_rdoc.pp'
|
116
|
+
klass = 'define_rdoc'
|
117
|
+
it_should_behave_like "standard tests", file, klass
|
118
|
+
it_should_behave_like "rdoc", file, klass
|
119
|
+
it_should_behave_like "nothing undocumented", file, klass
|
120
|
+
end
|
121
|
+
|
122
|
+
describe "define with no rdoc" do
|
123
|
+
file = 'spec/manifests/define_nordoc.pp'
|
124
|
+
klass = 'define_nordoc'
|
125
|
+
it_should_behave_like "standard tests", file, klass
|
126
|
+
it_should_behave_like "no rdoc", file, klass
|
127
|
+
it_should_behave_like "something undocumented", file, klass
|
128
|
+
end
|
129
|
+
|
130
|
+
end
|
131
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PuppetDocLint::DocRunner do
|
4
|
+
file = 'spec/manifests/define_rdoc.pp'
|
5
|
+
subject { setup(file) }
|
6
|
+
|
7
|
+
it 'result should be an array of PuppetDocLint::Result' do
|
8
|
+
subject.class.should be(Array)
|
9
|
+
subject[0].class.should be(PuppetDocLint::Result)
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'file name should be defined' do
|
13
|
+
subject[0].file_name.should eql 'spec/manifests/define_rdoc.pp'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'class should be define_rdoc ' do
|
17
|
+
subject[0].class_name.should eql 'define_rdoc'
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'all parameters should be defined' do
|
21
|
+
subject[0].parameters.should eql ["param_one", "param_two", "param_three", "param_four"]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'no documentation is nil' do
|
25
|
+
subject[0].no_documentation.should be_false
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'documented parameters' do
|
29
|
+
subject[0].documented_parameters.should eql ["param_one"]
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'undocumented_parameters parameters' do
|
33
|
+
subject[0].undocumented_parameters.should eql ["param_two", "param_three", "param_four"]
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'puppet-doc-lint'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
5
|
+
config.run_all_when_everything_filtered = true
|
6
|
+
config.filter_run :focus
|
7
|
+
|
8
|
+
config.order = 'random'
|
9
|
+
end
|
10
|
+
|
11
|
+
def setup(file)
|
12
|
+
runner = PuppetDocLint::Runner.new
|
13
|
+
manifests = [ file ]
|
14
|
+
runner.run(manifests)
|
15
|
+
end
|
16
|
+
|
17
|
+
def setup_folder(files)
|
18
|
+
runner = PuppetDocLint::Runner.new
|
19
|
+
runner.run(files)
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,173 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: puppet-doc-lint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Peter Souter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.14.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.14.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.1.1
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.1.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rdoc
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
- - <
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '4.0'
|
51
|
+
type: :runtime
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.12'
|
58
|
+
- - <
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4.0'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: facter
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ~>
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.6'
|
68
|
+
type: :runtime
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ~>
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '1.6'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: puppet
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 3.4.2
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 3.4.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: virtus
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: 1.0.1
|
96
|
+
type: :runtime
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ~>
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 1.0.1
|
103
|
+
description: Doc Parser for Puppet Modules. Returns Information about documentation.
|
104
|
+
email:
|
105
|
+
- p.morsou@gmail.com
|
106
|
+
executables:
|
107
|
+
- puppet-doc-lint
|
108
|
+
extensions: []
|
109
|
+
extra_rdoc_files: []
|
110
|
+
files:
|
111
|
+
- .gitignore
|
112
|
+
- .rspec
|
113
|
+
- .travis.yml
|
114
|
+
- CHANGELOG.md
|
115
|
+
- Gemfile
|
116
|
+
- LICENSE
|
117
|
+
- README.md
|
118
|
+
- Rakefile
|
119
|
+
- bin/puppet-doc-lint
|
120
|
+
- lib/puppet-doc-lint.rb
|
121
|
+
- lib/puppet-doc-lint/configuration.rb
|
122
|
+
- lib/puppet-doc-lint/doc_runner.rb
|
123
|
+
- lib/puppet-doc-lint/hash.rb
|
124
|
+
- lib/puppet-doc-lint/parser.rb
|
125
|
+
- lib/puppet-doc-lint/rake_task.rb
|
126
|
+
- lib/puppet-doc-lint/result.rb
|
127
|
+
- lib/puppet-doc-lint/runner.rb
|
128
|
+
- lib/puppet-doc-lint/version.rb
|
129
|
+
- puppet-doc-lint.gemspec
|
130
|
+
- spec/manifests/define_nordoc.pp
|
131
|
+
- spec/manifests/define_rdoc.pp
|
132
|
+
- spec/manifests/noclass.pp
|
133
|
+
- spec/manifests/noparameters_nordoc.pp
|
134
|
+
- spec/manifests/noparameters_rdoc.pp
|
135
|
+
- spec/manifests/parameters_nordoc.pp
|
136
|
+
- spec/manifests/parameters_rdoc.pp
|
137
|
+
- spec/runner_acceptance_spec.rb
|
138
|
+
- spec/runner_results_spec.rb
|
139
|
+
- spec/spec_helper.rb
|
140
|
+
homepage: https://github.com/petems/puppet-doc-lint
|
141
|
+
licenses: []
|
142
|
+
metadata: {}
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
require_paths:
|
146
|
+
- lib
|
147
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: 1.9.2
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - '>='
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '0'
|
157
|
+
requirements: []
|
158
|
+
rubyforge_project:
|
159
|
+
rubygems_version: 2.0.3
|
160
|
+
signing_key:
|
161
|
+
specification_version: 4
|
162
|
+
summary: Doc Parser for Puppet Modules. Returns Information about documentation.
|
163
|
+
test_files:
|
164
|
+
- spec/manifests/define_nordoc.pp
|
165
|
+
- spec/manifests/define_rdoc.pp
|
166
|
+
- spec/manifests/noclass.pp
|
167
|
+
- spec/manifests/noparameters_nordoc.pp
|
168
|
+
- spec/manifests/noparameters_rdoc.pp
|
169
|
+
- spec/manifests/parameters_nordoc.pp
|
170
|
+
- spec/manifests/parameters_rdoc.pp
|
171
|
+
- spec/runner_acceptance_spec.rb
|
172
|
+
- spec/runner_results_spec.rb
|
173
|
+
- spec/spec_helper.rb
|