puppet-strings 2.9.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +261 -237
- data/README.md +52 -65
- data/lib/puppet/face/strings.rb +30 -50
- data/lib/puppet/feature/rgen.rb +1 -1
- data/lib/puppet/feature/yard.rb +1 -1
- data/lib/puppet-strings/describe.rb +18 -18
- data/lib/puppet-strings/markdown/base.rb +63 -28
- data/lib/puppet-strings/markdown/data_type.rb +4 -0
- data/lib/puppet-strings/markdown/defined_type.rb +4 -0
- data/lib/puppet-strings/markdown/function.rb +13 -8
- data/lib/puppet-strings/markdown/helpers.rb +21 -0
- data/lib/puppet-strings/markdown/puppet_class.rb +4 -0
- data/lib/puppet-strings/markdown/puppet_plan.rb +4 -0
- data/lib/puppet-strings/markdown/puppet_task.rb +4 -1
- data/lib/puppet-strings/markdown/resource_type.rb +13 -3
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +4 -4
- data/lib/puppet-strings/markdown/templates/data_type.erb +5 -9
- data/lib/puppet-strings/markdown/templates/data_type_function.erb +1 -1
- data/lib/puppet-strings/markdown/templates/function.erb +1 -1
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +1 -1
- data/lib/puppet-strings/markdown/templates/resource_type.erb +6 -6
- data/lib/puppet-strings/markdown/templates/table_of_contents.erb +8 -8
- data/lib/puppet-strings/markdown.rb +62 -20
- data/lib/puppet-strings/monkey_patches/display_object_command.rb +4 -1
- data/lib/puppet-strings/tasks/generate.rb +8 -10
- data/lib/puppet-strings/tasks/gh_pages.rb +6 -5
- data/lib/puppet-strings/tasks/validate.rb +1 -1
- data/lib/puppet-strings/tasks.rb +8 -7
- data/lib/puppet-strings/version.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/class.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/data_type.rb +4 -4
- data/lib/puppet-strings/yard/code_objects/data_type_alias.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/defined_type.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/function.rb +11 -11
- data/lib/puppet-strings/yard/code_objects/group.rb +1 -1
- data/lib/puppet-strings/yard/code_objects/plan.rb +4 -2
- data/lib/puppet-strings/yard/code_objects/provider.rb +2 -2
- data/lib/puppet-strings/yard/code_objects/task.rb +6 -7
- data/lib/puppet-strings/yard/code_objects/type.rb +6 -6
- data/lib/puppet-strings/yard/handlers/helpers.rb +3 -4
- data/lib/puppet-strings/yard/handlers/json/base.rb +2 -1
- data/lib/puppet-strings/yard/handlers/json/task_handler.rb +4 -4
- data/lib/puppet-strings/yard/handlers/puppet/base.rb +7 -2
- data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +3 -2
- data/lib/puppet-strings/yard/handlers/ruby/base.rb +3 -2
- data/lib/puppet-strings/yard/handlers/ruby/data_type_handler.rb +19 -16
- data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +70 -50
- data/lib/puppet-strings/yard/handlers/ruby/provider_handler.rb +2 -1
- data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +12 -9
- data/lib/puppet-strings/yard/handlers/ruby/type_base.rb +27 -27
- data/lib/puppet-strings/yard/handlers/ruby/type_extras_handler.rb +2 -3
- data/lib/puppet-strings/yard/handlers/ruby/type_handler.rb +2 -1
- data/lib/puppet-strings/yard/parsers/json/parser.rb +3 -2
- data/lib/puppet-strings/yard/parsers/json/task_statement.rb +3 -3
- data/lib/puppet-strings/yard/parsers/puppet/parser.rb +7 -7
- data/lib/puppet-strings/yard/parsers/puppet/statement.rb +16 -23
- data/lib/puppet-strings/yard/parsers.rb +1 -0
- data/lib/puppet-strings/yard/tags/enum_tag.rb +1 -2
- data/lib/puppet-strings/yard/tags/factory.rb +1 -1
- data/lib/puppet-strings/yard/tags/overload_tag.rb +7 -7
- data/lib/puppet-strings/yard/tags/parameter_directive.rb +2 -2
- data/lib/puppet-strings/yard/tags/property_directive.rb +2 -2
- data/lib/puppet-strings/yard/tags/summary_tag.rb +1 -2
- data/lib/puppet-strings/yard/util.rb +11 -4
- data/lib/puppet-strings/yard.rb +6 -6
- data/lib/puppet-strings.rb +7 -13
- metadata +13 -20
- data/lib/puppet-strings/markdown/data_types.rb +0 -43
- data/lib/puppet-strings/markdown/defined_types.rb +0 -39
- data/lib/puppet-strings/markdown/functions.rb +0 -40
- data/lib/puppet-strings/markdown/puppet_classes.rb +0 -39
- data/lib/puppet-strings/markdown/puppet_plans.rb +0 -39
- data/lib/puppet-strings/markdown/puppet_tasks.rb +0 -36
- data/lib/puppet-strings/markdown/resource_types.rb +0 -39
- data/lib/puppet-strings/markdown/table_of_contents.rb +0 -26
@@ -21,15 +21,15 @@ class PuppetStrings::Yard::Tags::OverloadTag < YARD::Tags::Tag
|
|
21
21
|
# @return [String] Returns the signature of the overload.
|
22
22
|
def signature
|
23
23
|
tags = self.tags(:param)
|
24
|
-
args = @parameters.map
|
24
|
+
args = @parameters.map { |parameter|
|
25
25
|
name, default = parameter
|
26
26
|
tag = tags.find { |t| t.name == name } if tags
|
27
27
|
type = tag&.types ? "#{tag.type} " : 'Any '
|
28
|
-
prefix =
|
28
|
+
prefix = (name[0]).to_s if name.start_with?('*', '&')
|
29
29
|
name = name[1..-1] if prefix
|
30
30
|
default = " = #{default}" if default
|
31
31
|
"#{type}#{prefix}$#{name}#{default}"
|
32
|
-
|
32
|
+
}.join(', ')
|
33
33
|
@name + '(' + args + ')'
|
34
34
|
end
|
35
35
|
|
@@ -57,7 +57,7 @@ class PuppetStrings::Yard::Tags::OverloadTag < YARD::Tags::Tag
|
|
57
57
|
# Determines if a tag with the given name is present.
|
58
58
|
# @param [String, Symbol] name The tag name.
|
59
59
|
# @return [Boolean] Returns true if there is at least one tag with the given name or false if not.
|
60
|
-
def has_tag?(name)
|
60
|
+
def has_tag?(name) # rubocop:disable Naming/PredicateName
|
61
61
|
@docstring.has_tag?(name)
|
62
62
|
end
|
63
63
|
|
@@ -67,7 +67,7 @@ class PuppetStrings::Yard::Tags::OverloadTag < YARD::Tags::Tag
|
|
67
67
|
def object=(value)
|
68
68
|
super(value)
|
69
69
|
@docstring.object = value
|
70
|
-
@docstring.tags.each {|tag| tag.object = value }
|
70
|
+
@docstring.tags.each { |tag| tag.object = value }
|
71
71
|
end
|
72
72
|
|
73
73
|
# Responsible for forwarding method calls to the associated object.
|
@@ -102,8 +102,8 @@ class PuppetStrings::Yard::Tags::OverloadTag < YARD::Tags::Tag
|
|
102
102
|
hash[:tag_name] = tag_name
|
103
103
|
hash[:text] = text if text
|
104
104
|
hash[:signature] = signature
|
105
|
-
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring)
|
106
|
-
defaults = Hash[*parameters.reject{ |p| p[1].nil? }.flatten]
|
105
|
+
hash[:docstring] = PuppetStrings::Yard::Util.docstring_to_hash(docstring) unless docstring.blank?
|
106
|
+
defaults = Hash[*parameters.reject { |p| p[1].nil? }.flatten]
|
107
107
|
hash[:defaults] = defaults unless defaults.empty?
|
108
108
|
hash[:types] = types if types
|
109
109
|
hash[:name] = name if name
|
@@ -12,8 +12,8 @@ class PuppetStrings::Yard::Tags::ParameterDirective < YARD::Tags::Directive
|
|
12
12
|
# Add a parameter to the resource
|
13
13
|
parameter = PuppetStrings::Yard::CodeObjects::Type::Parameter.new(tag.name, tag.text)
|
14
14
|
tag.types&.each do |value|
|
15
|
-
|
16
|
-
|
15
|
+
parameter.add(value)
|
16
|
+
end
|
17
17
|
object.add_parameter parameter
|
18
18
|
end
|
19
19
|
|
@@ -12,8 +12,8 @@ class PuppetStrings::Yard::Tags::PropertyDirective < YARD::Tags::Directive
|
|
12
12
|
# Add a property to the resource
|
13
13
|
property = PuppetStrings::Yard::CodeObjects::Type::Property.new(tag.name, tag.text)
|
14
14
|
tag.types&.each do |value|
|
15
|
-
|
16
|
-
|
15
|
+
property.add(value)
|
16
|
+
end
|
17
17
|
object.add_property property
|
18
18
|
end
|
19
19
|
|
@@ -1,11 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Implements a summary tag for general purpose short descriptions
|
4
|
-
|
5
4
|
class PuppetStrings::Yard::Tags::SummaryTag < YARD::Tags::Tag
|
6
5
|
# Registers the tag with YARD.
|
7
6
|
# @return [void]
|
8
7
|
def self.register!
|
9
|
-
YARD::Tags::Library.define_tag(
|
8
|
+
YARD::Tags::Library.define_tag('puppet.summary', :summary)
|
10
9
|
end
|
11
10
|
end
|
@@ -9,7 +9,7 @@ module PuppetStrings::Yard::Util
|
|
9
9
|
# @param [String] str The string to scrub.
|
10
10
|
# @return [String] A scrubbed string.
|
11
11
|
def self.scrub_string(str)
|
12
|
-
match = str.match(
|
12
|
+
match = str.match(%r{^%[Qq]{(.*)}$}m)
|
13
13
|
if match
|
14
14
|
return Puppet::Util::Docs.scrub(match[1])
|
15
15
|
end
|
@@ -25,8 +25,8 @@ module PuppetStrings::Yard::Util
|
|
25
25
|
# @param [String] data HTML document to convert
|
26
26
|
# @return [String] HTML document with links converted
|
27
27
|
def self.github_to_yard_links(data)
|
28
|
-
data.scan(
|
29
|
-
data = data.gsub("=\"##{bad_link.first}\"", "=\"#label-#{bad_link.first.capitalize.
|
28
|
+
data.scan(%r{href\=\"\#(.+)\"}).each do |bad_link|
|
29
|
+
data = data.gsub("=\"##{bad_link.first}\"", "=\"#label-#{bad_link.first.capitalize.tr('-', '+')}\"")
|
30
30
|
end
|
31
31
|
|
32
32
|
data
|
@@ -59,7 +59,7 @@ module PuppetStrings::Yard::Util
|
|
59
59
|
# @param [YARD::Docstring, String] docstring The docstring to convert to a hash.
|
60
60
|
# @param [Array] select_tags List of tags to select. Other tags will be filtered out.
|
61
61
|
# @return [Hash] Returns a hash representation of the given docstring.
|
62
|
-
def self.docstring_to_hash(docstring, select_tags=nil)
|
62
|
+
def self.docstring_to_hash(docstring, select_tags = nil)
|
63
63
|
hash = {}
|
64
64
|
hash[:text] = docstring
|
65
65
|
|
@@ -79,4 +79,11 @@ module PuppetStrings::Yard::Util
|
|
79
79
|
|
80
80
|
hash
|
81
81
|
end
|
82
|
+
|
83
|
+
# Convert Puppet AST to text.
|
84
|
+
# @param [Puppet::Pops::Model::PopsObject] ast The Puppet AST to convert to text.
|
85
|
+
# @return [String] Returns a string of Puppet code.
|
86
|
+
def self.ast_to_text(ast)
|
87
|
+
ast.locator.extract_tree_text(ast)
|
88
|
+
end
|
82
89
|
end
|
data/lib/puppet-strings/yard.rb
CHANGED
@@ -61,7 +61,7 @@ class YARD::CLI::Yardoc
|
|
61
61
|
:puppet_provider,
|
62
62
|
:puppet_function,
|
63
63
|
:puppet_task,
|
64
|
-
:puppet_plan
|
64
|
+
:puppet_plan,
|
65
65
|
)
|
66
66
|
end
|
67
67
|
end
|
@@ -114,18 +114,18 @@ class YARD::CLI::Stats
|
|
114
114
|
@undocumented += undoc if undoc.is_a?(Integer)
|
115
115
|
data =
|
116
116
|
if undoc
|
117
|
-
|
117
|
+
"#{data} (#{undoc} undocumented)"
|
118
118
|
else
|
119
|
-
|
119
|
+
data.to_s
|
120
120
|
end
|
121
|
-
log.puts(
|
121
|
+
log.puts("#{name.ljust(25)} #{data}")
|
122
122
|
end
|
123
123
|
|
124
124
|
# This differs from the YARD implementation in that it considers
|
125
125
|
# a docstring without text but with tags to be undocumented.
|
126
126
|
def type_statistics_all(type)
|
127
|
-
objs = all_objects.select {|m| m.type == type }
|
128
|
-
undoc = objs.
|
127
|
+
objs = all_objects.select { |m| m.type == type }
|
128
|
+
undoc = objs.select { |m| m.docstring.all.empty? }
|
129
129
|
@undoc_list |= undoc if @undoc_list
|
130
130
|
[objs.size, undoc.size]
|
131
131
|
end
|
data/lib/puppet-strings.rb
CHANGED
@@ -1,16 +1,11 @@
|
|
1
|
+
# rubocop:disable Naming/FileName
|
2
|
+
|
1
3
|
# frozen_string_literal: true
|
2
4
|
|
3
5
|
# The root module for Puppet Strings.
|
4
6
|
module PuppetStrings
|
5
7
|
# The glob patterns used to search for files to document.
|
6
|
-
DEFAULT_SEARCH_PATTERNS =
|
7
|
-
manifests/**/*.pp
|
8
|
-
functions/**/*.pp
|
9
|
-
types/**/*.pp
|
10
|
-
lib/**/*.rb
|
11
|
-
tasks/*.json
|
12
|
-
plans/**/*.pp
|
13
|
-
).freeze
|
8
|
+
DEFAULT_SEARCH_PATTERNS = ['manifests/**/*.pp', 'functions/**/*.pp', 'types/**/*.pp', 'lib/**/*.rb', 'tasks/*.json', 'plans/**/*.pp'].freeze
|
14
9
|
|
15
10
|
# Generates documentation.
|
16
11
|
# @param [Array<String>] search_patterns The search patterns (e.g. manifests/**/*.pp) to look for files.
|
@@ -39,7 +34,7 @@ module PuppetStrings
|
|
39
34
|
file = if options[:json]
|
40
35
|
options[:path]
|
41
36
|
elsif options[:markdown]
|
42
|
-
options[:path] ||
|
37
|
+
options[:path] || 'REFERENCE.md'
|
43
38
|
end
|
44
39
|
# Disable output and prevent stats/progress when writing to STDOUT
|
45
40
|
args << '-n'
|
@@ -64,13 +59,12 @@ module PuppetStrings
|
|
64
59
|
render_markdown(file)
|
65
60
|
end
|
66
61
|
|
67
|
-
|
68
|
-
|
69
|
-
end
|
62
|
+
return unless options[:describe]
|
63
|
+
render_describe(options[:describe_types], options[:describe_list], options[:providers])
|
70
64
|
end
|
71
65
|
|
72
66
|
def self.puppet_5?
|
73
|
-
Puppet::Util::Package.versioncmp(Puppet.version,
|
67
|
+
Puppet::Util::Package.versioncmp(Puppet.version, '5.0.0') >= 0
|
74
68
|
end
|
75
69
|
|
76
70
|
def self.render_json(path)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-strings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Puppet Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: yard
|
@@ -28,17 +28,17 @@ dependencies:
|
|
28
28
|
name: rgen
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.9.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
41
|
-
description:
|
40
|
+
version: 0.9.0
|
41
|
+
description:
|
42
42
|
email: info@puppet.com
|
43
43
|
executables: []
|
44
44
|
extensions: []
|
@@ -60,20 +60,13 @@ files:
|
|
60
60
|
- lib/puppet-strings/markdown.rb
|
61
61
|
- lib/puppet-strings/markdown/base.rb
|
62
62
|
- lib/puppet-strings/markdown/data_type.rb
|
63
|
-
- lib/puppet-strings/markdown/data_types.rb
|
64
63
|
- lib/puppet-strings/markdown/defined_type.rb
|
65
|
-
- lib/puppet-strings/markdown/defined_types.rb
|
66
64
|
- lib/puppet-strings/markdown/function.rb
|
67
|
-
- lib/puppet-strings/markdown/
|
65
|
+
- lib/puppet-strings/markdown/helpers.rb
|
68
66
|
- lib/puppet-strings/markdown/puppet_class.rb
|
69
|
-
- lib/puppet-strings/markdown/puppet_classes.rb
|
70
67
|
- lib/puppet-strings/markdown/puppet_plan.rb
|
71
|
-
- lib/puppet-strings/markdown/puppet_plans.rb
|
72
68
|
- lib/puppet-strings/markdown/puppet_task.rb
|
73
|
-
- lib/puppet-strings/markdown/puppet_tasks.rb
|
74
69
|
- lib/puppet-strings/markdown/resource_type.rb
|
75
|
-
- lib/puppet-strings/markdown/resource_types.rb
|
76
|
-
- lib/puppet-strings/markdown/table_of_contents.rb
|
77
70
|
- lib/puppet-strings/markdown/templates/classes_and_defines.erb
|
78
71
|
- lib/puppet-strings/markdown/templates/data_type.erb
|
79
72
|
- lib/puppet-strings/markdown/templates/data_type_function.erb
|
@@ -228,7 +221,7 @@ homepage: https://github.com/puppetlabs/puppet-strings
|
|
228
221
|
licenses:
|
229
222
|
- Apache-2.0
|
230
223
|
metadata: {}
|
231
|
-
post_install_message:
|
224
|
+
post_install_message:
|
232
225
|
rdoc_options: []
|
233
226
|
require_paths:
|
234
227
|
- lib
|
@@ -236,16 +229,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
236
229
|
requirements:
|
237
230
|
- - ">="
|
238
231
|
- !ruby/object:Gem::Version
|
239
|
-
version: 2.
|
232
|
+
version: 2.7.0
|
240
233
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
234
|
requirements:
|
242
235
|
- - ">="
|
243
236
|
- !ruby/object:Gem::Version
|
244
237
|
version: '0'
|
245
238
|
requirements:
|
246
|
-
- puppet, >=
|
239
|
+
- puppet, >= 6.0.0
|
247
240
|
rubygems_version: 3.1.6
|
248
|
-
signing_key:
|
241
|
+
signing_key:
|
249
242
|
specification_version: 4
|
250
243
|
summary: Puppet documentation via YARD
|
251
244
|
test_files: []
|
@@ -1,43 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'data_type'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module DataTypes
|
7
|
-
|
8
|
-
# @return [Array] list of data types
|
9
|
-
def self.in_dtypes
|
10
|
-
arr = YARD::Registry.all(:puppet_data_type).map!(&:to_hash)
|
11
|
-
arr.concat(YARD::Registry.all(:puppet_data_type_alias).map!(&:to_hash))
|
12
|
-
|
13
|
-
arr.sort! { |a,b| a[:name] <=> b[:name] }
|
14
|
-
arr.map! { |a| PuppetStrings::Markdown::DataType.new(a) }
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.contains_private?
|
18
|
-
result = false
|
19
|
-
unless in_dtypes.nil?
|
20
|
-
in_dtypes.find { |type| type.private? }.nil? ? false : true
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.render
|
25
|
-
final = in_dtypes.length > 0 ? "## Data types\n\n" : ""
|
26
|
-
in_dtypes.each do |type|
|
27
|
-
final += type.render unless type.private?
|
28
|
-
end
|
29
|
-
final
|
30
|
-
end
|
31
|
-
|
32
|
-
|
33
|
-
def self.toc_info
|
34
|
-
final = ["Data types"]
|
35
|
-
|
36
|
-
in_dtypes.each do |type|
|
37
|
-
final.push(type.toc_info)
|
38
|
-
end
|
39
|
-
|
40
|
-
final
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'defined_type'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module DefinedTypes
|
7
|
-
|
8
|
-
# @return [Array] list of defined types
|
9
|
-
def self.in_dtypes
|
10
|
-
arr = YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash)
|
11
|
-
arr.map! { |a| PuppetStrings::Markdown::DefinedType.new(a) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.contains_private?
|
15
|
-
result = false
|
16
|
-
unless in_dtypes.nil?
|
17
|
-
in_dtypes.find { |type| type.private? }.nil? ? false : true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.render
|
22
|
-
final = in_dtypes.length > 0 ? "## Defined types\n\n" : ""
|
23
|
-
in_dtypes.each do |type|
|
24
|
-
final += type.render unless type.private?
|
25
|
-
end
|
26
|
-
final
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.toc_info
|
30
|
-
final = ["Defined types"]
|
31
|
-
|
32
|
-
in_dtypes.each do |type|
|
33
|
-
final.push(type.toc_info)
|
34
|
-
end
|
35
|
-
|
36
|
-
final
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'function'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module Functions
|
7
|
-
|
8
|
-
# @return [Array] list of functions
|
9
|
-
def self.in_functions
|
10
|
-
arr = YARD::Registry.all(:puppet_function).sort_by!(&:name).map!(&:to_hash)
|
11
|
-
arr.map! { |a| PuppetStrings::Markdown::Function.new(a) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.contains_private?
|
15
|
-
result = false
|
16
|
-
unless in_functions.nil?
|
17
|
-
in_functions.find { |func| func.private? }.nil? ? false : true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.render
|
22
|
-
final = in_functions.length > 0 ? "## Functions\n\n" : ""
|
23
|
-
in_functions.each do |func|
|
24
|
-
final += func.render unless func.private?
|
25
|
-
end
|
26
|
-
final
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.toc_info
|
30
|
-
final = ["Functions"]
|
31
|
-
|
32
|
-
in_functions.each do |func|
|
33
|
-
final.push(func.toc_info)
|
34
|
-
end
|
35
|
-
|
36
|
-
final
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'puppet_class'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module PuppetClasses
|
7
|
-
|
8
|
-
# @return [Array] list of classes
|
9
|
-
def self.in_classes
|
10
|
-
arr = YARD::Registry.all(:puppet_class).sort_by!(&:name).map!(&:to_hash)
|
11
|
-
arr.map! { |a| PuppetStrings::Markdown::PuppetClass.new(a) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.contains_private?
|
15
|
-
result = false
|
16
|
-
unless in_classes.nil?
|
17
|
-
in_classes.find { |klass| klass.private? }.nil? ? false : true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.render
|
22
|
-
final = in_classes.length > 0 ? "## Classes\n\n" : ""
|
23
|
-
in_classes.each do |klass|
|
24
|
-
final += klass.render unless klass.private?
|
25
|
-
end
|
26
|
-
final
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.toc_info
|
30
|
-
final = ["Classes"]
|
31
|
-
|
32
|
-
in_classes.each do |klass|
|
33
|
-
final.push(klass.toc_info)
|
34
|
-
end
|
35
|
-
|
36
|
-
final
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'puppet_plan'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module PuppetPlans
|
7
|
-
|
8
|
-
# @return [Array] list of classes
|
9
|
-
def self.in_plans
|
10
|
-
arr = YARD::Registry.all(:puppet_plan).sort_by!(&:name).map!(&:to_hash)
|
11
|
-
arr.map! { |a| PuppetStrings::Markdown::PuppetPlan.new(a) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.contains_private?
|
15
|
-
result = false
|
16
|
-
unless in_plans.nil?
|
17
|
-
in_plans.find { |plan| plan.private? }.nil? ? false : true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.render
|
22
|
-
final = in_plans.length > 0 ? "## Plans\n\n" : ""
|
23
|
-
in_plans.each do |plan|
|
24
|
-
final += plan.render unless plan.private?
|
25
|
-
end
|
26
|
-
final
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.toc_info
|
30
|
-
final = ["Plans"]
|
31
|
-
|
32
|
-
in_plans.each do |plan|
|
33
|
-
final.push(plan.toc_info)
|
34
|
-
end
|
35
|
-
|
36
|
-
final
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'puppet_task'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module PuppetTasks
|
7
|
-
|
8
|
-
# @return [Array] list of classes
|
9
|
-
def self.in_tasks
|
10
|
-
arr = YARD::Registry.all(:puppet_task).sort_by!(&:name).map!(&:to_hash)
|
11
|
-
arr.map! { |a| PuppetStrings::Markdown::PuppetTask.new(a) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.contains_private?
|
15
|
-
false
|
16
|
-
end
|
17
|
-
|
18
|
-
def self.render
|
19
|
-
final = in_tasks.length > 0 ? "## Tasks\n\n" : ""
|
20
|
-
in_tasks.each do |task|
|
21
|
-
final += task.render unless task.private?
|
22
|
-
end
|
23
|
-
final
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.toc_info
|
27
|
-
final = ["Tasks"]
|
28
|
-
|
29
|
-
in_tasks.each do |task|
|
30
|
-
final.push(task.toc_info)
|
31
|
-
end
|
32
|
-
|
33
|
-
final
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'resource_type'
|
4
|
-
|
5
|
-
module PuppetStrings::Markdown
|
6
|
-
module ResourceTypes
|
7
|
-
|
8
|
-
# @return [Array] list of resource types
|
9
|
-
def self.in_rtypes
|
10
|
-
arr = YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash)
|
11
|
-
arr.map! { |a| PuppetStrings::Markdown::ResourceType.new(a) }
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.contains_private?
|
15
|
-
result = false
|
16
|
-
unless in_rtypes.nil?
|
17
|
-
in_rtypes.find { |type| type.private? }.nil? ? false : true
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def self.render
|
22
|
-
final = in_rtypes.length > 0 ? "## Resource types\n\n" : ""
|
23
|
-
in_rtypes.each do |type|
|
24
|
-
final += type.render unless type.private?
|
25
|
-
end
|
26
|
-
final
|
27
|
-
end
|
28
|
-
|
29
|
-
def self.toc_info
|
30
|
-
final = ["Resource types"]
|
31
|
-
|
32
|
-
in_rtypes.each do |type|
|
33
|
-
final.push(type.toc_info)
|
34
|
-
end
|
35
|
-
|
36
|
-
final
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PuppetStrings::Markdown
|
4
|
-
module TableOfContents
|
5
|
-
def self.render
|
6
|
-
final = "## Table of Contents\n\n"
|
7
|
-
|
8
|
-
[PuppetStrings::Markdown::PuppetClasses,
|
9
|
-
PuppetStrings::Markdown::DefinedTypes,
|
10
|
-
PuppetStrings::Markdown::ResourceTypes,
|
11
|
-
PuppetStrings::Markdown::Functions,
|
12
|
-
PuppetStrings::Markdown::DataTypes,
|
13
|
-
PuppetStrings::Markdown::PuppetTasks,
|
14
|
-
PuppetStrings::Markdown::PuppetPlans].each do |r|
|
15
|
-
toc = r.toc_info
|
16
|
-
group_name = toc.shift
|
17
|
-
group = toc
|
18
|
-
priv = r.contains_private?
|
19
|
-
|
20
|
-
template = File.join(File.dirname(__FILE__),"templates/table_of_contents.erb")
|
21
|
-
final += ERB.new(File.read(template), nil, '-').result(binding)
|
22
|
-
end
|
23
|
-
final
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|