puppet-strings 0.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 +7 -0
- data/lib/puppet-strings/rake_tasks.rb +18 -0
- data/lib/puppet/application/strings.rb +4 -0
- data/lib/puppet/face/strings.rb +64 -0
- data/lib/puppet/feature/rgen.rb +3 -0
- data/lib/puppet/feature/yard.rb +3 -0
- data/lib/puppet_x/puppetlabs/strings.rb +64 -0
- data/lib/puppet_x/puppetlabs/strings/actions.rb +92 -0
- data/lib/puppet_x/puppetlabs/strings/pops/yard_statement.rb +79 -0
- data/lib/puppet_x/puppetlabs/strings/pops/yard_transformer.rb +47 -0
- data/lib/puppet_x/puppetlabs/strings/util.rb +65 -0
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/defined_type_object.rb +33 -0
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/host_class_object.rb +22 -0
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb +62 -0
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/provider_object.rb +24 -0
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/puppet_namespace_object.rb +48 -0
- data/lib/puppet_x/puppetlabs/strings/yard/code_objects/type_object.rb +42 -0
- data/lib/puppet_x/puppetlabs/strings/yard/core_ext/yard.rb +40 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/base.rb +13 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/defined_type_handler.rb +31 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/heredoc_helper.rb +80 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb +42 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/provider_handler.rb +95 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_3x_function_handler.rb +54 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_4x_function_handler.rb +234 -0
- data/lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb +295 -0
- data/lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb +85 -0
- data/lib/puppet_x/puppetlabs/strings/yard/monkey_patches.rb +68 -0
- data/lib/puppet_x/puppetlabs/strings/yard/parser.rb +30 -0
- data/lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb +9 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/docstring.erb +34 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/header.erb +5 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/parameter_details.erb +6 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/setup.rb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb +49 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_class.erb +2 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_manifest.erb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_plugin.erb +21 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_provider.erb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_type.erb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb +82 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/box_info.erb +22 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/setup.rb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/subclasses.erb +4 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/setup.rb +21 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/html_helper.rb +139 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/layout/html/setup.rb +18 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/html/header.erb +17 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/setup.rb +21 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/text/header.erb +2 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/command_details.erb +8 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/confine_details.erb +10 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/default_details.erb +10 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/docstring.erb +34 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/feature_details.erb +10 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/header.erb +5 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/setup.rb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb +50 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/box_info.erb +11 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/header.erb +5 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_details_list.erb +53 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_summary.erb +20 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/setup.rb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb +91 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/template_helper.rb +192 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/docstring.erb +34 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/header.erb +5 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/parameter_details.erb +12 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/provider_details.erb +10 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/setup.rb +1 -0
- data/lib/puppet_x/puppetlabs/strings/yard/templates/default/type/setup.rb +55 -0
- metadata +142 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include T('default/module/html')
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
include T('default/module')
|
|
2
|
+
|
|
3
|
+
require File.join(File.dirname(__FILE__),'../html_helper')
|
|
4
|
+
require File.join(File.dirname(__FILE__),'../template_helper')
|
|
5
|
+
|
|
6
|
+
def init
|
|
7
|
+
sections :header, :box_info,
|
|
8
|
+
:method_summary, [:item_summary],
|
|
9
|
+
:method_details_list, [T('method_details')]
|
|
10
|
+
|
|
11
|
+
@methods = object.children
|
|
12
|
+
@template_helper = TemplateHelper.new
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def header
|
|
16
|
+
# The list is expected to only contain one type of function
|
|
17
|
+
if @methods[0]['puppet_4x_function']
|
|
18
|
+
@header_text = "Puppet 4 Functions"
|
|
19
|
+
else
|
|
20
|
+
@header_text = "Puppet 3 Functions"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
erb(:header)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def box_info
|
|
27
|
+
@source_files = []
|
|
28
|
+
|
|
29
|
+
@methods.each do |method|
|
|
30
|
+
# extract the file name and line number for each method
|
|
31
|
+
file_name = method.files[0][0]
|
|
32
|
+
line_number = method.files[0][1]
|
|
33
|
+
|
|
34
|
+
@source_files.push([method.name, "#{file_name} (#{line_number})"])
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
erb(:box_info)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def method_summary
|
|
41
|
+
@method_details = []
|
|
42
|
+
@html_helper = HTMLHelper.new
|
|
43
|
+
|
|
44
|
+
@methods.each do |method|
|
|
45
|
+
# If there are multiple sentences in the method description, only
|
|
46
|
+
# use the first one for the summary. If the author did not include
|
|
47
|
+
# any periods in their summary, include the whole thing
|
|
48
|
+
first_sentence = method.docstring.match(/^(.*?)\./)
|
|
49
|
+
brief_summary = first_sentence ? first_sentence : method.docstring
|
|
50
|
+
|
|
51
|
+
return_tag = method.tags.find { |tag| tag.tag_name == "return"}
|
|
52
|
+
return_types = return_tag.nil? ? nil : return_tag.types
|
|
53
|
+
|
|
54
|
+
@method_details.push({:name => method.name, :short_desc => brief_summary, :return_types => return_types})
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
erb(:method_summary)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def method_details_list
|
|
61
|
+
@class_details = []
|
|
62
|
+
@html_helper = HTMLHelper.new
|
|
63
|
+
|
|
64
|
+
@methods.each do |object|
|
|
65
|
+
|
|
66
|
+
method_info = @template_helper.extract_tag_data(object)
|
|
67
|
+
param_details = nil
|
|
68
|
+
param_tags = object.tags.find_all{ |tag| tag.tag_name == "param"}
|
|
69
|
+
|
|
70
|
+
if object['puppet_4x_function']
|
|
71
|
+
# Extract the source code
|
|
72
|
+
source_code = object.source
|
|
73
|
+
# Extract the parameters for the source code
|
|
74
|
+
parameters = source_code.match(/(?:def .*)\((.*?)\)/)
|
|
75
|
+
# Convert the matched string into an array of strings
|
|
76
|
+
params = parameters.nil? ? nil : parameters[1].split(/\s*,\s*/)
|
|
77
|
+
|
|
78
|
+
param_details = @template_helper.extract_param_details(params, param_tags) unless params.nil?
|
|
79
|
+
@template_helper.check_types_match_docs object, param_details
|
|
80
|
+
@template_helper.check_parameters_match_docs object
|
|
81
|
+
else
|
|
82
|
+
param_details = @template_helper.comment_only_param_details(param_tags)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
method_info[:params] = param_details
|
|
86
|
+
|
|
87
|
+
@class_details.push(method_info)
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
erb(:method_details_list)
|
|
91
|
+
end
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
require "puppet"
|
|
2
|
+
|
|
3
|
+
# A class containing helper methods to aid in the extraction of relevant data
|
|
4
|
+
# from comments and YARD tags
|
|
5
|
+
class TemplateHelper
|
|
6
|
+
# Extracts data from comments which include the supported YARD tags
|
|
7
|
+
def extract_tag_data(object)
|
|
8
|
+
examples = Hash.new
|
|
9
|
+
example_tags = object.tags.find_all { |tag| tag.tag_name == "example" }
|
|
10
|
+
example_tags.each do |example|
|
|
11
|
+
examples["#{example.name}"] = example.text
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
return_tag = object.tags.find { |tag| tag.tag_name == "return"}
|
|
15
|
+
return_text = return_tag.nil? ? nil : return_tag.text
|
|
16
|
+
return_types = return_tag.nil? ? nil : return_tag.types
|
|
17
|
+
return_details = (return_text.nil? && return_types.nil?) ? nil : [return_text, return_types]
|
|
18
|
+
|
|
19
|
+
since_tag = object.tags.find { |tag| tag.tag_name == "since"}
|
|
20
|
+
since_text = since_tag.nil? ? nil : since_tag.text
|
|
21
|
+
|
|
22
|
+
{:name => object.name, :desc => object.docstring, :examples => examples, :since => since_text, :return => return_details}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
# Given the parameter information and YARD param tags, extracts the
|
|
26
|
+
# useful information and returns it as an array of hashes which can
|
|
27
|
+
# be printed and formatted as HTML
|
|
28
|
+
#
|
|
29
|
+
# @param parameters [Array] parameter details obtained programmatically
|
|
30
|
+
# @param tags_hash [Array] parameter details obtained from comments
|
|
31
|
+
# @param fq_name [Boolean] does this parameter have a fully qualified name?
|
|
32
|
+
#
|
|
33
|
+
# @return [Hash] The relevant information about each parameter with the following keys/values:
|
|
34
|
+
# {:name => [String] The name of the parameter
|
|
35
|
+
# :fq_name => [String] The fully qualified parameter name
|
|
36
|
+
# :desc => [String] The description provided in the comment
|
|
37
|
+
# :types => [Array] The parameter type(s) specified in the comment
|
|
38
|
+
# :exists => [Boolean] True only if the parameter exists in the documented logic and not just in a comment}
|
|
39
|
+
def extract_param_details(parameters, tags_hash, fq_name = false)
|
|
40
|
+
parameter_info = []
|
|
41
|
+
|
|
42
|
+
# Extract the information for parameters that exist
|
|
43
|
+
# as opposed to parameters that are defined only in the comments
|
|
44
|
+
parameters.each do |param|
|
|
45
|
+
if fq_name
|
|
46
|
+
param_name = param[0]
|
|
47
|
+
fully_qualified_name = param[1]
|
|
48
|
+
else
|
|
49
|
+
param_name = param
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
param_tag = tags_hash.find { |tag| tag.name == param_name }
|
|
53
|
+
|
|
54
|
+
description = param_tag.nil? ? nil : param_tag.text
|
|
55
|
+
param_types = param_tag.nil? ? nil : param_tag.types
|
|
56
|
+
|
|
57
|
+
param_details = {:name => param_name, :desc => description, :types => param_types, :exists? => true}
|
|
58
|
+
|
|
59
|
+
if fq_name
|
|
60
|
+
param_details[:fq_name] = fully_qualified_name
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
parameter_info.push(param_details)
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Check if there were any comments for parameters that do not exist
|
|
67
|
+
tags_hash.each do |tag|
|
|
68
|
+
param_exists = false
|
|
69
|
+
parameter_info.each do |parameter|
|
|
70
|
+
if parameter[:name] == tag.name
|
|
71
|
+
param_exists = true
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
if !param_exists
|
|
75
|
+
parameter_info.push({:name => tag.name, :desc => tag.text, :types => tag.types, :exists? => false})
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
parameter_info
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# Generates parameter information in situations where the information can only
|
|
83
|
+
# come from YARD tags in the comments, not from the code itself. For now the only
|
|
84
|
+
# use for this is 3x functions. In this case exists? will always be true since we
|
|
85
|
+
# cannot verify if the parameter exists in the code itself. We must trust the user
|
|
86
|
+
# to provide information in the comments that is accurate.
|
|
87
|
+
#
|
|
88
|
+
# @param param_tags [Array] parameter details obtained from comments
|
|
89
|
+
#
|
|
90
|
+
# @return [Hash] The relevant information about each parameter with the following keys/values:
|
|
91
|
+
# {:name => [String] The name of the parameter
|
|
92
|
+
# :desc => [String] The description provided in the comment
|
|
93
|
+
# :types => [Array] The parameter type(s) specified in the comment
|
|
94
|
+
# :exists => [Boolean] True only if the parameter exists in the documented logic and not just in a comment
|
|
95
|
+
# :puppet_3_func => [Boolean] Are these parameters for a puppet 3 function? (relevant in HTML generation)}
|
|
96
|
+
def comment_only_param_details(param_tags)
|
|
97
|
+
return if param_tags.empty?
|
|
98
|
+
|
|
99
|
+
parameter_info = []
|
|
100
|
+
|
|
101
|
+
param_tags.each do |tag|
|
|
102
|
+
parameter_info.push({:name => tag.name, :desc => tag.text, :types => tag.types, :exists? => true, :puppet_3_func => true})
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
parameter_info
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Check that any types specified in the docstrings match the actual method
|
|
109
|
+
# types. This is used by puppet 4x functions and defined types.
|
|
110
|
+
# @param object the code object to examine for parameters names
|
|
111
|
+
def check_types_match_docs(object, params_hash)
|
|
112
|
+
# We'll need this to extract type info from the type specified by the
|
|
113
|
+
# docstring.
|
|
114
|
+
type_parser = Puppet::Pops::Types::TypeParser.new
|
|
115
|
+
type_calculator = Puppet::Pops::Types::TypeCalculator.new
|
|
116
|
+
|
|
117
|
+
object.type_info.each do |function|
|
|
118
|
+
function.keys.each do |key|
|
|
119
|
+
if function[key].class == String
|
|
120
|
+
begin
|
|
121
|
+
instantiated = type_parser.parse function[key]
|
|
122
|
+
rescue Puppet::ParseError
|
|
123
|
+
# Likely the result of a malformed type
|
|
124
|
+
next
|
|
125
|
+
end
|
|
126
|
+
else
|
|
127
|
+
instantiated = function[key]
|
|
128
|
+
end
|
|
129
|
+
params_hash.each do |param|
|
|
130
|
+
if param[:name] == key and param[:types] != nil
|
|
131
|
+
param[:types].each do |type|
|
|
132
|
+
param_instantiated = type_parser.parse type
|
|
133
|
+
if not type_calculator.assignable? instantiated, param_instantiated
|
|
134
|
+
actual_types = object.type_info.map do |sig|
|
|
135
|
+
sig[key].to_s if sig[key]
|
|
136
|
+
end.compact
|
|
137
|
+
# Get the locations where the object can be found. We only care about
|
|
138
|
+
# the first one.
|
|
139
|
+
locations = object.files
|
|
140
|
+
warning = <<-EOS
|
|
141
|
+
[warn]: @param tag types do not match the code. The #{param[:name]}
|
|
142
|
+
parameter is declared as types #{param[:types]} in the docstring,
|
|
143
|
+
but the code specifies the types #{actual_types}
|
|
144
|
+
EOS
|
|
145
|
+
|
|
146
|
+
# If the locations aren't in the shape we expect then report that
|
|
147
|
+
# the file number couldn't be determined.
|
|
148
|
+
if locations.length >= 1 and locations[0].length == 2
|
|
149
|
+
file = locations[0][0]
|
|
150
|
+
line = locations[0][1]
|
|
151
|
+
warning += " in the file #{file} near line #{line}."
|
|
152
|
+
else
|
|
153
|
+
warning += " Sorry, the file and line number could " +
|
|
154
|
+
"not be determined."
|
|
155
|
+
end
|
|
156
|
+
$stderr.puts warning
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
# Check that the actual function parameters match what is stated in the docs.
|
|
166
|
+
# If there is a mismatch, print a warning to stderr.
|
|
167
|
+
# This is necessary for puppet classes and defined types. This type of
|
|
168
|
+
# warning will be issued for ruby code by the ruby docstring parser.
|
|
169
|
+
# @param object the code object to examine for parameters names
|
|
170
|
+
def check_parameters_match_docs(object)
|
|
171
|
+
param_tags = object.tags.find_all{ |tag| tag.tag_name == "param"}
|
|
172
|
+
names = object.parameters.map {|l| l.first.gsub(/\W/, '') }
|
|
173
|
+
locations = object.files
|
|
174
|
+
param_tags.each do |tag|
|
|
175
|
+
if not names.include?(tag.name)
|
|
176
|
+
if locations.length >= 1 and locations[0].length == 2
|
|
177
|
+
file_name = locations[0][0]
|
|
178
|
+
line_number = locations[0][1]
|
|
179
|
+
$stderr.puts <<-EOS
|
|
180
|
+
[warn]: The parameter #{tag.name} is documented, but doesn't exist in
|
|
181
|
+
your code, in file #{file_name} near line #{line_number}.
|
|
182
|
+
EOS
|
|
183
|
+
else
|
|
184
|
+
$stderr.puts <<-EOS
|
|
185
|
+
[warn]: The parameter #{tag.name} is documented, but doesn't exist in
|
|
186
|
+
your code. Sorry, the file and line number could not be determined.
|
|
187
|
+
EOS
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
end
|
|
192
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<div class="docstring">
|
|
2
|
+
<div class="discussion">
|
|
3
|
+
<p><%= htmlify(Puppet::Util::Docs::scrub(@class_details[:desc])) %></p>
|
|
4
|
+
</div>
|
|
5
|
+
</div>
|
|
6
|
+
<div class="tags">
|
|
7
|
+
<% if @class_details[:examples] != {}%>
|
|
8
|
+
<div class="examples">
|
|
9
|
+
<p class="tag_title">Examples:</p>
|
|
10
|
+
<% @class_details[:examples].each do |title, text| %>
|
|
11
|
+
<div class="inline"><p><%= title %></p></div>
|
|
12
|
+
<pre class="example code"><code><span><%= text %></span></code></pre>
|
|
13
|
+
<% end %>
|
|
14
|
+
</div>
|
|
15
|
+
<% end %>
|
|
16
|
+
<% if @class_details[:since] %>
|
|
17
|
+
<p class="tag_title">Since:</p>
|
|
18
|
+
<ul class="since">
|
|
19
|
+
<li>
|
|
20
|
+
<div class="inline">
|
|
21
|
+
<p><%= @class_details[:since] %></p>
|
|
22
|
+
</div>
|
|
23
|
+
</li>
|
|
24
|
+
</ul>
|
|
25
|
+
<% end %>
|
|
26
|
+
<% if @class_details[:return] %>
|
|
27
|
+
<p class="tag_title">Return:</p>
|
|
28
|
+
<ul class="return">
|
|
29
|
+
<li>
|
|
30
|
+
<%= @html_helper.generate_return_types(@class_details[:return][1], @class_details[:return][0]) %>
|
|
31
|
+
</li>
|
|
32
|
+
</ul>
|
|
33
|
+
<% end %>
|
|
34
|
+
</div>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<h2>Parameter Summary</h2>
|
|
2
|
+
<div class="tags">
|
|
3
|
+
<ul class="param">
|
|
4
|
+
<%= @html_helper.generate_parameters(@param_details, object) %>
|
|
5
|
+
</ul>
|
|
6
|
+
</div>
|
|
7
|
+
<h2>Features</h2>
|
|
8
|
+
<div class="tags">
|
|
9
|
+
<ul class="feature">
|
|
10
|
+
<%= @html_helper.generate_features(@feature_details, object) %>
|
|
11
|
+
</ul>
|
|
12
|
+
</div>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<h2>Available Providers</h2>
|
|
2
|
+
<% if @providers != [] %>
|
|
3
|
+
<div class="tags">
|
|
4
|
+
<ul class="command">
|
|
5
|
+
<% @providers.each do |provider| %>
|
|
6
|
+
<li><a href="<%= provider.name.to_s %>.html"><tt><%= provider.name.to_s %></tt></a></li>
|
|
7
|
+
<% end %>
|
|
8
|
+
</ul>
|
|
9
|
+
</div>
|
|
10
|
+
<% end %>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include T('default/module/html')
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
include T('default/module')
|
|
2
|
+
|
|
3
|
+
require File.join(File.dirname(__FILE__),'../html_helper')
|
|
4
|
+
require File.join(File.dirname(__FILE__),'../template_helper')
|
|
5
|
+
|
|
6
|
+
def init
|
|
7
|
+
sections :header, :box_info, :pre_docstring, :docstring, :parameter_details, :provider_details
|
|
8
|
+
|
|
9
|
+
@template_helper = TemplateHelper.new
|
|
10
|
+
@html_helper = HTMLHelper.new
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def header
|
|
14
|
+
@header_text = object.header_name
|
|
15
|
+
|
|
16
|
+
erb(:header)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def provider_details
|
|
20
|
+
type_name = object.name.to_s
|
|
21
|
+
@providers = YARD::Registry.all(:provider).select { |t| t.type_name == type_name }
|
|
22
|
+
|
|
23
|
+
erb(:provider_details)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def parameter_details
|
|
27
|
+
params = object.parameter_details.map { |h| h[:name] }
|
|
28
|
+
# Put properties and parameters in one big list where the descriptions are
|
|
29
|
+
# scrubbed and htmlified and the namevar is the first element, the ensure
|
|
30
|
+
# property the second, and the rest are alphabetized.
|
|
31
|
+
@param_details = (object.parameter_details + object.property_details).each {
|
|
32
|
+
|h| h[:desc] = htmlify(Puppet::Util::Docs::scrub(h[:desc])) if h[:desc]
|
|
33
|
+
}.sort { |a, b| a[:name] <=> b[:name] }
|
|
34
|
+
# Float ensurable and namevars to the top of the list
|
|
35
|
+
@param_details = @param_details.partition{|a| a[:name] == 'ensure'}.flatten
|
|
36
|
+
@param_details = @param_details.partition{|a| a[:namevar]}.flatten
|
|
37
|
+
|
|
38
|
+
@feature_details = object.features
|
|
39
|
+
@template_helper.check_parameters_match_docs object
|
|
40
|
+
|
|
41
|
+
erb(:parameter_details)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def header
|
|
45
|
+
@header_text = "Puppet Type: #{object.name}"
|
|
46
|
+
|
|
47
|
+
erb(:header)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def docstring
|
|
51
|
+
|
|
52
|
+
@class_details = @template_helper.extract_tag_data(object)
|
|
53
|
+
|
|
54
|
+
erb(:docstring)
|
|
55
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: puppet-strings
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.4.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Puppet Labs
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: puppet
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 3.7.0
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ">="
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.7.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: yard
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0.8'
|
|
34
|
+
type: :runtime
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0.8'
|
|
41
|
+
description: Puppet documentation via YARD
|
|
42
|
+
email: info@puppetlabs.com
|
|
43
|
+
executables: []
|
|
44
|
+
extensions: []
|
|
45
|
+
extra_rdoc_files: []
|
|
46
|
+
files:
|
|
47
|
+
- lib/puppet-strings/rake_tasks.rb
|
|
48
|
+
- lib/puppet/application/strings.rb
|
|
49
|
+
- lib/puppet/face/strings.rb
|
|
50
|
+
- lib/puppet/feature/rgen.rb
|
|
51
|
+
- lib/puppet/feature/yard.rb
|
|
52
|
+
- lib/puppet_x/puppetlabs/strings.rb
|
|
53
|
+
- lib/puppet_x/puppetlabs/strings/actions.rb
|
|
54
|
+
- lib/puppet_x/puppetlabs/strings/pops/yard_statement.rb
|
|
55
|
+
- lib/puppet_x/puppetlabs/strings/pops/yard_transformer.rb
|
|
56
|
+
- lib/puppet_x/puppetlabs/strings/util.rb
|
|
57
|
+
- lib/puppet_x/puppetlabs/strings/yard/code_objects/defined_type_object.rb
|
|
58
|
+
- lib/puppet_x/puppetlabs/strings/yard/code_objects/host_class_object.rb
|
|
59
|
+
- lib/puppet_x/puppetlabs/strings/yard/code_objects/method_object.rb
|
|
60
|
+
- lib/puppet_x/puppetlabs/strings/yard/code_objects/provider_object.rb
|
|
61
|
+
- lib/puppet_x/puppetlabs/strings/yard/code_objects/puppet_namespace_object.rb
|
|
62
|
+
- lib/puppet_x/puppetlabs/strings/yard/code_objects/type_object.rb
|
|
63
|
+
- lib/puppet_x/puppetlabs/strings/yard/core_ext/yard.rb
|
|
64
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/base.rb
|
|
65
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/defined_type_handler.rb
|
|
66
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/heredoc_helper.rb
|
|
67
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/host_class_handler.rb
|
|
68
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/provider_handler.rb
|
|
69
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_3x_function_handler.rb
|
|
70
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/puppet_4x_function_handler.rb
|
|
71
|
+
- lib/puppet_x/puppetlabs/strings/yard/handlers/type_handler.rb
|
|
72
|
+
- lib/puppet_x/puppetlabs/strings/yard/json_registry_store.rb
|
|
73
|
+
- lib/puppet_x/puppetlabs/strings/yard/monkey_patches.rb
|
|
74
|
+
- lib/puppet_x/puppetlabs/strings/yard/parser.rb
|
|
75
|
+
- lib/puppet_x/puppetlabs/strings/yard/tags/directives.rb
|
|
76
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/docstring.erb
|
|
77
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/header.erb
|
|
78
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/parameter_details.erb
|
|
79
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/html/setup.rb
|
|
80
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/definedtype/setup.rb
|
|
81
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_class.erb
|
|
82
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_manifest.erb
|
|
83
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_plugin.erb
|
|
84
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_provider.erb
|
|
85
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/full_list_puppet_type.erb
|
|
86
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/fulldoc/html/setup.rb
|
|
87
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/box_info.erb
|
|
88
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/setup.rb
|
|
89
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/html/subclasses.erb
|
|
90
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/hostclass/setup.rb
|
|
91
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/html_helper.rb
|
|
92
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/layout/html/setup.rb
|
|
93
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/html/header.erb
|
|
94
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/setup.rb
|
|
95
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/method_details/text/header.erb
|
|
96
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/command_details.erb
|
|
97
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/confine_details.erb
|
|
98
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/default_details.erb
|
|
99
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/docstring.erb
|
|
100
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/feature_details.erb
|
|
101
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/header.erb
|
|
102
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/html/setup.rb
|
|
103
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/provider/setup.rb
|
|
104
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/box_info.erb
|
|
105
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/header.erb
|
|
106
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_details_list.erb
|
|
107
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/method_summary.erb
|
|
108
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/html/setup.rb
|
|
109
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/puppetnamespace/setup.rb
|
|
110
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/template_helper.rb
|
|
111
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/docstring.erb
|
|
112
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/header.erb
|
|
113
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/parameter_details.erb
|
|
114
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/provider_details.erb
|
|
115
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/type/html/setup.rb
|
|
116
|
+
- lib/puppet_x/puppetlabs/strings/yard/templates/default/type/setup.rb
|
|
117
|
+
homepage: https://github.com/puppetlabs/puppetlabs-strings
|
|
118
|
+
licenses:
|
|
119
|
+
- Apache-2.0
|
|
120
|
+
metadata: {}
|
|
121
|
+
post_install_message:
|
|
122
|
+
rdoc_options: []
|
|
123
|
+
require_paths:
|
|
124
|
+
- lib
|
|
125
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
126
|
+
requirements:
|
|
127
|
+
- - ">="
|
|
128
|
+
- !ruby/object:Gem::Version
|
|
129
|
+
version: '0'
|
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
131
|
+
requirements:
|
|
132
|
+
- - ">="
|
|
133
|
+
- !ruby/object:Gem::Version
|
|
134
|
+
version: '0'
|
|
135
|
+
requirements: []
|
|
136
|
+
rubyforge_project:
|
|
137
|
+
rubygems_version: 2.4.5
|
|
138
|
+
signing_key:
|
|
139
|
+
specification_version: 4
|
|
140
|
+
summary: Puppet documentation via YARD
|
|
141
|
+
test_files: []
|
|
142
|
+
has_rdoc:
|