puppet-strings 1.2.1 → 2.0.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 +4 -4
- data/CHANGELOG.md +26 -0
- data/CONTRIBUTING.md +3 -7
- data/JSON.md +126 -8
- data/README.md +16 -498
- data/lib/puppet-strings.rb +6 -0
- data/lib/puppet-strings/json.rb +2 -0
- data/lib/puppet-strings/markdown.rb +6 -1
- data/lib/puppet-strings/markdown/puppet_plan.rb +14 -0
- data/lib/puppet-strings/markdown/puppet_plans.rb +37 -0
- data/lib/puppet-strings/markdown/puppet_task.rb +24 -0
- data/lib/puppet-strings/markdown/puppet_tasks.rb +34 -0
- data/lib/puppet-strings/markdown/table_of_contents.rb +3 -1
- data/lib/puppet-strings/markdown/templates/classes_and_defines.erb +8 -5
- data/lib/puppet-strings/markdown/templates/function.erb +2 -3
- data/lib/puppet-strings/markdown/templates/puppet_task.erb +28 -0
- data/lib/puppet-strings/markdown/templates/resource_type.erb +9 -5
- data/lib/puppet-strings/markdown/templates/table_of_contents.erb +5 -0
- data/lib/puppet-strings/monkey_patches/display_object_command.rb +11 -0
- data/lib/puppet-strings/yard.rb +15 -1
- data/lib/puppet-strings/yard/code_objects.rb +2 -0
- data/lib/puppet-strings/yard/code_objects/plan.rb +56 -0
- data/lib/puppet-strings/yard/code_objects/task.rb +70 -0
- data/lib/puppet-strings/yard/handlers.rb +6 -0
- data/lib/puppet-strings/yard/handlers/json/base.rb +5 -0
- data/lib/puppet-strings/yard/handlers/json/task_handler.rb +31 -0
- data/lib/puppet-strings/yard/handlers/puppet/base.rb +1 -1
- data/lib/puppet-strings/yard/handlers/puppet/class_handler.rb +1 -1
- data/lib/puppet-strings/yard/handlers/puppet/defined_type_handler.rb +1 -1
- data/lib/puppet-strings/yard/handlers/puppet/function_handler.rb +1 -1
- data/lib/puppet-strings/yard/handlers/puppet/plan_handler.rb +27 -0
- data/lib/puppet-strings/yard/handlers/ruby/function_handler.rb +4 -1
- data/lib/puppet-strings/yard/handlers/ruby/rsapi_handler.rb +12 -2
- data/lib/puppet-strings/yard/parsers.rb +4 -0
- data/lib/puppet-strings/yard/parsers/json/parser.rb +33 -0
- data/lib/puppet-strings/yard/parsers/json/task_statement.rb +35 -0
- data/lib/puppet-strings/yard/parsers/puppet/parser.rb +11 -0
- data/lib/puppet-strings/yard/parsers/puppet/statement.rb +14 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_plan.erb +9 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/full_list_puppet_task.erb +9 -0
- data/lib/puppet-strings/yard/templates/default/fulldoc/html/setup.rb +18 -0
- data/lib/puppet-strings/yard/templates/default/layout/html/setup.rb +42 -2
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/box_info.erb +10 -0
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/setup.rb +11 -0
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/source.erb +12 -0
- data/lib/puppet-strings/yard/templates/default/puppet_plan/html/summary.erb +4 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/box_info.erb +9 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/header.erb +1 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/input.erb +5 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/overview.erb +6 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/parameters.erb +16 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/setup.rb +22 -0
- data/lib/puppet-strings/yard/templates/default/puppet_task/html/supports_noop.erb +3 -0
- data/lib/puppet-strings/yard/templates/default/tags/setup.rb +3 -1
- data/lib/puppet-strings/yard/util.rb +14 -0
- data/spec/fixtures/unit/json/output.json +50 -0
- data/spec/fixtures/unit/json/output_with_plan.json +689 -0
- data/spec/fixtures/unit/markdown/output.md +63 -8
- data/spec/fixtures/unit/markdown/output_with_plan.md +472 -0
- data/spec/spec_helper.rb +5 -2
- data/spec/unit/puppet-strings/json_spec.rb +42 -2
- data/spec/unit/puppet-strings/markdown_spec.rb +41 -8
- data/spec/unit/puppet-strings/yard/code_objects/task_spec.rb +92 -0
- data/spec/unit/puppet-strings/yard/handlers/json/task_handler_spec.rb +124 -0
- data/spec/unit/puppet-strings/yard/handlers/puppet/class_handler_spec.rb +1 -1
- data/spec/unit/puppet-strings/yard/handlers/puppet/defined_type_handler_spec.rb +19 -12
- data/spec/unit/puppet-strings/yard/handlers/ruby/function_handler_spec.rb +33 -0
- data/spec/unit/puppet-strings/yard/handlers/ruby/rsapi_handler_spec.rb +8 -7
- data/spec/unit/puppet-strings/yard/parsers/json/parser_spec.rb +70 -0
- data/spec/unit/puppet-strings/yard/parsers/json/task_statement_spec.rb +56 -0
- data/spec/unit/puppet-strings/yard/parsers/puppet/parser_spec.rb +1 -1
- data/spec/unit/puppet-strings/yard/util_spec.rb +17 -0
- metadata +38 -5
- data/MAINTAINERS +0 -17
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'puppet-strings/yard/code_objects/group'
|
2
|
+
|
3
|
+
# Implements the group for Puppet tasks.
|
4
|
+
class PuppetStrings::Yard::CodeObjects::Tasks < PuppetStrings::Yard::CodeObjects::Group
|
5
|
+
# Gets the singleton instance of the group.
|
6
|
+
# @return Returns the singleton instance of the group.
|
7
|
+
def self.instance
|
8
|
+
super(:puppet_tasks)
|
9
|
+
end
|
10
|
+
|
11
|
+
# Gets the display name of the group.
|
12
|
+
# @param [Boolean] prefix whether to show a prefix.
|
13
|
+
# @return [String] Returns the display name of the group.
|
14
|
+
def name(prefix = false)
|
15
|
+
'Puppet Tasks'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Implements the Puppet task code object.
|
20
|
+
class PuppetStrings::Yard::CodeObjects::Task < PuppetStrings::Yard::CodeObjects::Base
|
21
|
+
attr_reader :statement
|
22
|
+
|
23
|
+
# Initializes a JSON task code object.
|
24
|
+
# @param statement TaskStatement object
|
25
|
+
# @return [void]
|
26
|
+
def initialize(statement)
|
27
|
+
@name = statement.name
|
28
|
+
@statement = statement
|
29
|
+
super(PuppetStrings::Yard::CodeObjects::Tasks.instance, name)
|
30
|
+
end
|
31
|
+
|
32
|
+
# Gets the type of the code object.
|
33
|
+
# @return Returns the type of the code object.
|
34
|
+
def type
|
35
|
+
:puppet_task
|
36
|
+
end
|
37
|
+
|
38
|
+
# Gets the source of the code object.
|
39
|
+
# @return Returns the source of the code object.
|
40
|
+
def source
|
41
|
+
@statement.source
|
42
|
+
end
|
43
|
+
|
44
|
+
def parameters
|
45
|
+
parameters = []
|
46
|
+
statement.json['parameters'].each do |name,props|
|
47
|
+
parameters.push({ name: name.to_s,
|
48
|
+
tag_name: 'param',
|
49
|
+
text: props['description'] || "",
|
50
|
+
types: [props['type']] || "" })
|
51
|
+
end
|
52
|
+
parameters
|
53
|
+
end
|
54
|
+
|
55
|
+
# Converts the code object to a hash representation.
|
56
|
+
# @return [Hash] Returns a hash representation of the code object.
|
57
|
+
def to_hash
|
58
|
+
{ name: name.to_s,
|
59
|
+
file: statement.file,
|
60
|
+
line: statement.line,
|
61
|
+
docstring: {
|
62
|
+
text: statement.docstring,
|
63
|
+
tags: parameters
|
64
|
+
},
|
65
|
+
source: statement.source,
|
66
|
+
supports_noop: statement.json['supports_noop'] || false,
|
67
|
+
input_method: statement.json['input_method']
|
68
|
+
}
|
69
|
+
end
|
70
|
+
end
|
@@ -8,10 +8,16 @@ module PuppetStrings::Yard::Handlers
|
|
8
8
|
require 'puppet-strings/yard/handlers/ruby/function_handler'
|
9
9
|
end
|
10
10
|
|
11
|
+
# The module for custom JSON YARD handlers.
|
12
|
+
module JSON
|
13
|
+
require 'puppet-strings/yard/handlers/json/task_handler'
|
14
|
+
end
|
15
|
+
|
11
16
|
# The module for custom Puppet YARD handlers.
|
12
17
|
module Puppet
|
13
18
|
require 'puppet-strings/yard/handlers/puppet/class_handler'
|
14
19
|
require 'puppet-strings/yard/handlers/puppet/defined_type_handler'
|
15
20
|
require 'puppet-strings/yard/handlers/puppet/function_handler'
|
21
|
+
require 'puppet-strings/yard/handlers/puppet/plan_handler'
|
16
22
|
end
|
17
23
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'puppet-strings/yard/handlers/json/base'
|
2
|
+
require 'puppet-strings/yard/parsers'
|
3
|
+
require 'puppet-strings/yard/parsers/json/parser'
|
4
|
+
|
5
|
+
class PuppetStrings::Yard::Handlers::JSON::TaskHandler < PuppetStrings::Yard::Handlers::JSON::Base
|
6
|
+
handles PuppetStrings::Yard::Parsers::JSON::TaskStatement
|
7
|
+
namespace_only
|
8
|
+
|
9
|
+
process do
|
10
|
+
object = PuppetStrings::Yard::CodeObjects::Task.new(statement)
|
11
|
+
register object
|
12
|
+
|
13
|
+
@kind = "Puppet Task #{object.name}."
|
14
|
+
@statement = statement
|
15
|
+
|
16
|
+
validate_description
|
17
|
+
validate_params
|
18
|
+
end
|
19
|
+
|
20
|
+
def validate_description
|
21
|
+
log.warn "Missing a description for #{@kind}." if @statement.docstring.empty?
|
22
|
+
end
|
23
|
+
|
24
|
+
def validate_params
|
25
|
+
unless @statement.parameters.empty?
|
26
|
+
@statement.parameters.each do |param, val|
|
27
|
+
log.warn "Missing description for param '#{param}' in #{@kind}" if val['description'].nil?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -17,7 +17,7 @@ class PuppetStrings::Yard::Handlers::Puppet::Base < YARD::Handlers::Base
|
|
17
17
|
tags = object.tags(:param)
|
18
18
|
tags.each do |tag|
|
19
19
|
next if statement.parameters.find { |p| tag.name == p.name }
|
20
|
-
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}."
|
20
|
+
log.warn "The @param tag for parameter '#{tag.name}' has no matching parameter at #{statement.file}:#{statement.line}." unless tag.name == 'name' || tag.name == 'title'
|
21
21
|
end
|
22
22
|
|
23
23
|
# Assign the types for the parameter
|
@@ -13,7 +13,7 @@ class PuppetStrings::Yard::Handlers::Puppet::ClassHandler < PuppetStrings::Yard:
|
|
13
13
|
register object
|
14
14
|
|
15
15
|
# Log a warning if missing documentation
|
16
|
-
log.warn "Missing documentation for Puppet class '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty?
|
16
|
+
log.warn "Missing documentation for Puppet class '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty?
|
17
17
|
|
18
18
|
# Set the parameter types
|
19
19
|
set_parameter_types(object)
|
@@ -13,7 +13,7 @@ class PuppetStrings::Yard::Handlers::Puppet::DefinedTypeHandler < PuppetStrings:
|
|
13
13
|
register object
|
14
14
|
|
15
15
|
# Log a warning if missing documentation
|
16
|
-
log.warn "Missing documentation for Puppet defined type '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty?
|
16
|
+
log.warn "Missing documentation for Puppet defined type '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty?
|
17
17
|
|
18
18
|
# Set the parameter types
|
19
19
|
set_parameter_types(object)
|
@@ -15,7 +15,7 @@ class PuppetStrings::Yard::Handlers::Puppet::FunctionHandler < PuppetStrings::Ya
|
|
15
15
|
register object
|
16
16
|
|
17
17
|
# Log a warning if missing documentation
|
18
|
-
log.warn "Missing documentation for Puppet function '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty?
|
18
|
+
log.warn "Missing documentation for Puppet function '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty?
|
19
19
|
|
20
20
|
# Set the parameter tag types
|
21
21
|
set_parameter_types(object)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'puppet-strings/yard/handlers/helpers'
|
2
|
+
require 'puppet-strings/yard/handlers/puppet/base'
|
3
|
+
require 'puppet-strings/yard/parsers'
|
4
|
+
require 'puppet-strings/yard/code_objects'
|
5
|
+
|
6
|
+
# Implements the handler for Puppet classes.
|
7
|
+
class PuppetStrings::Yard::Handlers::Puppet::PlanHandler < PuppetStrings::Yard::Handlers::Puppet::Base
|
8
|
+
handles PuppetStrings::Yard::Parsers::Puppet::PlanStatement
|
9
|
+
|
10
|
+
process do
|
11
|
+
# Register the object
|
12
|
+
object = PuppetStrings::Yard::CodeObjects::Plan.new(statement)
|
13
|
+
register object
|
14
|
+
|
15
|
+
# Log a warning if missing documentation
|
16
|
+
log.warn "Missing documentation for Puppet plan '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty?
|
17
|
+
|
18
|
+
# Set the parameter types
|
19
|
+
set_parameter_types(object)
|
20
|
+
|
21
|
+
# Mark the class as public if it doesn't already have an api tag
|
22
|
+
object.add_tag YARD::Tags::Tag.new(:api, 'public') unless object.has_tag? :api
|
23
|
+
|
24
|
+
# Warn if a summary longer than 140 characters was provided
|
25
|
+
PuppetStrings::Yard::Handlers::Helpers.validate_summary_tag(object) if object.has_tag? :summary
|
26
|
+
end
|
27
|
+
end
|
@@ -77,7 +77,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def add_tags(object)
|
80
|
-
log.warn "Missing documentation for Puppet function '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty?
|
80
|
+
log.warn "Missing documentation for Puppet function '#{object.name}' at #{statement.file}:#{statement.line}." if object.docstring.empty? && object.tags.empty?
|
81
81
|
log.warn "The docstring for Puppet 4.x function '#{object.name}' contains @param tags near #{object.file}:#{object.line}: parameter documentation should be made on the dispatch call." unless object.tags(:param).empty?
|
82
82
|
log.warn "The docstring for Puppet 4.x function '#{object.name}' contains @return tags near #{object.file}:#{object.line}: return value documentation should be made on the dispatch call." unless object.tags(:return).empty?
|
83
83
|
log.warn "The docstring for Puppet 4.x function '#{object.name}' contains @overload tags near #{object.file}:#{object.line}: overload tags are automatically generated from the dispatch calls." unless object.tags(:overload).empty?
|
@@ -139,6 +139,9 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
|
|
139
139
|
next unless DISPATCH_METHOD_NAMES.include?(method_name)
|
140
140
|
|
141
141
|
if method_name == 'return_type'
|
142
|
+
# Add a return tag if missing
|
143
|
+
overload_tag.add_tag YARD::Tags::Tag.new(:return, '', 'Any') if overload_tag.tag(:return).nil?
|
144
|
+
|
142
145
|
overload_tag.tag(:return).types = [node_as_string(child.parameters[0])]
|
143
146
|
next
|
144
147
|
end
|
@@ -24,7 +24,7 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
24
24
|
object = PuppetStrings::Yard::CodeObjects::Type.new(schema['name'])
|
25
25
|
register object
|
26
26
|
|
27
|
-
docstring = schema['
|
27
|
+
docstring = schema['docs']
|
28
28
|
if docstring
|
29
29
|
register_docstring(object, PuppetStrings::Yard::Util.scrub_string(docstring.to_s), nil)
|
30
30
|
else
|
@@ -44,7 +44,7 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def raise_parse_error(msg, location = statement)
|
47
|
-
raise YARD::Parser::UndocumentableError, "#{msg} at #{location.file}:#{location.line}."
|
47
|
+
raise YARD::Parser::UndocumentableError, "#{msg} at #{location.file}:#{location.line}."
|
48
48
|
end
|
49
49
|
|
50
50
|
# check that the params of the register_type call are key/value pairs.
|
@@ -67,6 +67,8 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
67
67
|
node.source.to_i
|
68
68
|
when :hash
|
69
69
|
hash_from_node(node)
|
70
|
+
when :array
|
71
|
+
array_from_node(node)
|
70
72
|
when :var_ref
|
71
73
|
var_ref_from_node(node)
|
72
74
|
when :symbol, :symbol_literal, :label, :dyna_symbol, :string_literal
|
@@ -76,6 +78,14 @@ class PuppetStrings::Yard::Handlers::Ruby::RsapiHandler < PuppetStrings::Yard::H
|
|
76
78
|
end
|
77
79
|
end
|
78
80
|
|
81
|
+
def array_from_node(node)
|
82
|
+
return nil unless node
|
83
|
+
|
84
|
+
arr = node.children.collect do |assoc|
|
85
|
+
value_from_node(assoc.children[0])
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
79
89
|
def hash_from_node(node)
|
80
90
|
return nil unless node
|
81
91
|
|
@@ -1,5 +1,9 @@
|
|
1
1
|
# The module for custom YARD parsers.
|
2
2
|
module PuppetStrings::Yard::Parsers
|
3
|
+
# The module for custom YARD parsers for JSON.
|
4
|
+
module JSON
|
5
|
+
require 'puppet-strings/yard/parsers/json/parser'
|
6
|
+
end
|
3
7
|
# The module for custom YARD parsers for the Puppet language.
|
4
8
|
module Puppet
|
5
9
|
require 'puppet-strings/yard/parsers/puppet/parser'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'puppet-strings/yard/parsers/json/task_statement'
|
2
|
+
|
3
|
+
class PuppetStrings::Yard::Parsers::JSON::Parser < YARD::Parser::Base
|
4
|
+
attr_reader :file, :source
|
5
|
+
|
6
|
+
# Initializes the parser.
|
7
|
+
# @param [String] source The source being parsed.
|
8
|
+
# @param [String] filename The file name of the file being parsed.
|
9
|
+
# @return [void]
|
10
|
+
def initialize(source, filename)
|
11
|
+
@file = filename
|
12
|
+
@source = source
|
13
|
+
@statements = []
|
14
|
+
end
|
15
|
+
|
16
|
+
def enumerator
|
17
|
+
@statements
|
18
|
+
end
|
19
|
+
|
20
|
+
# Parses the source
|
21
|
+
# @return [void]
|
22
|
+
def parse
|
23
|
+
begin
|
24
|
+
json = JSON.parse(source)
|
25
|
+
@statements.push(PuppetStrings::Yard::Parsers::JSON::TaskStatement.new(json, @source, @file))
|
26
|
+
rescue
|
27
|
+
log.error "Failed to parse #{@file}: "
|
28
|
+
@statements = []
|
29
|
+
end
|
30
|
+
@statements.freeze
|
31
|
+
self
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module PuppetStrings::Yard::Parsers::JSON
|
2
|
+
# Represents the Puppet Task statement.
|
3
|
+
class TaskStatement
|
4
|
+
attr_reader :line, :comments, :comments_range, :json, :file, :source, :docstring
|
5
|
+
|
6
|
+
def initialize(json, source, file)
|
7
|
+
@file = file
|
8
|
+
@source = source
|
9
|
+
@json = json
|
10
|
+
@line = 0
|
11
|
+
@comments_range = nil
|
12
|
+
@docstring = YARD::Docstring.new(@json['description'])
|
13
|
+
end
|
14
|
+
|
15
|
+
def parameters
|
16
|
+
json['parameters'] || {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def comments_hash_flag
|
20
|
+
false
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
""
|
25
|
+
end
|
26
|
+
|
27
|
+
def comments
|
28
|
+
docstring.all
|
29
|
+
end
|
30
|
+
|
31
|
+
def name
|
32
|
+
File.basename(@file).gsub('.json','') || ""
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -20,6 +20,11 @@ class PuppetStrings::Yard::Parsers::Puppet::Parser < YARD::Parser::Base
|
|
20
20
|
# @return [void]
|
21
21
|
def parse
|
22
22
|
begin
|
23
|
+
Puppet[:tasks] = true if Puppet.settings.include?(:tasks)
|
24
|
+
if Puppet::Util::Package.versioncmp(Puppet.version, "5.0.0") < 0 && @file.to_s.match(/^plans\//)
|
25
|
+
log.warn "Skipping #{@file}: Puppet Plans require Puppet 5 or greater."
|
26
|
+
return
|
27
|
+
end
|
23
28
|
@statements ||= (@visitor.visit(::Puppet::Pops::Parser::Parser.new.parse_string(source)) || []).compact
|
24
29
|
rescue ::Puppet::ParseError => ex
|
25
30
|
log.error "Failed to parse #{@file}: #{ex.message}"
|
@@ -64,6 +69,12 @@ class PuppetStrings::Yard::Parsers::Puppet::Parser < YARD::Parser::Base
|
|
64
69
|
statement
|
65
70
|
end
|
66
71
|
|
72
|
+
def transform_PlanDefinition(o)
|
73
|
+
statement = PuppetStrings::Yard::Parsers::Puppet::PlanStatement.new(o, @file)
|
74
|
+
statement.extract_docstring(@lines)
|
75
|
+
statement
|
76
|
+
end
|
77
|
+
|
67
78
|
def transform_Object(o)
|
68
79
|
# Ignore anything else (will be compacted out of the resulting array)
|
69
80
|
end
|
@@ -151,4 +151,18 @@ module PuppetStrings::Yard::Parsers::Puppet
|
|
151
151
|
end
|
152
152
|
end
|
153
153
|
end
|
154
|
+
|
155
|
+
# Implements the Puppet plan statement.
|
156
|
+
class PlanStatement < ParameterizedStatement
|
157
|
+
attr_reader :name
|
158
|
+
|
159
|
+
# Initializes the Puppet plan statement.
|
160
|
+
# @param [Puppet::Pops::Model::PlanDefinition] object The model object for the plan statement.
|
161
|
+
# @param [String] file The file containing the statement.
|
162
|
+
def initialize(object, file)
|
163
|
+
super(object, file)
|
164
|
+
@name = object.name
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
154
168
|
end
|
@@ -62,3 +62,21 @@ def generate_class_list
|
|
62
62
|
@list_type = 'class'
|
63
63
|
generate_list_contents
|
64
64
|
end
|
65
|
+
|
66
|
+
# Generates the searchable Puppet Task list.
|
67
|
+
# @return [void]
|
68
|
+
def generate_puppet_task_list
|
69
|
+
@items = Registry.all(:puppet_task).sort_by {|t| t.name.to_s }
|
70
|
+
@list_title = 'Puppet Task List'
|
71
|
+
@list_type = 'puppet_task'
|
72
|
+
generate_list_contents
|
73
|
+
end
|
74
|
+
|
75
|
+
# Generates the searchable Puppet Plan list.
|
76
|
+
# @return [void]
|
77
|
+
def generate_puppet_plan_list
|
78
|
+
@items = Registry.all(:puppet_plan).sort_by {|t| t.name.to_s }
|
79
|
+
@list_title = 'Puppet Plan List'
|
80
|
+
@list_type = 'puppet_plan'
|
81
|
+
generate_list_contents
|
82
|
+
end
|
@@ -4,7 +4,7 @@ def init
|
|
4
4
|
case object
|
5
5
|
when '_index.html'
|
6
6
|
@page_title = options.title
|
7
|
-
sections :layout, [:index, [:listing, [:classes, :defined_types, :types, :providers, :functions, :files, :objects]]]
|
7
|
+
sections :layout, [:index, [:listing, [:classes, :defined_types, :types, :providers, :functions, :tasks, :plans, :files, :objects]]]
|
8
8
|
else
|
9
9
|
super
|
10
10
|
end
|
@@ -46,11 +46,25 @@ def layout
|
|
46
46
|
@nav_url = url_for_list('puppet_function')
|
47
47
|
@page_title = "Puppet Function: #{object.name} (#{object.function_type})"
|
48
48
|
@path = object.path
|
49
|
+
when PuppetStrings::Yard::CodeObjects::Task
|
50
|
+
@nav_url = url_for_list('puppet_task')
|
51
|
+
@page_title = "Puppet Task: #{object.name}"
|
52
|
+
@path = object.path
|
53
|
+
when PuppetStrings::Yard::CodeObjects::Plan
|
54
|
+
@nav_url = url_for_list('puppet_plan')
|
55
|
+
@page_title = "Puppet Plan: #{object.name}"
|
56
|
+
@path = object.path
|
49
57
|
else
|
50
58
|
@path = object.path
|
51
59
|
end
|
52
60
|
|
53
|
-
erb(:layout)
|
61
|
+
final_layout = erb(:layout)
|
62
|
+
|
63
|
+
if @file && @file.name == 'README'
|
64
|
+
PuppetStrings::Yard::Util.github_to_yard_links(final_layout)
|
65
|
+
end
|
66
|
+
|
67
|
+
final_layout
|
54
68
|
end
|
55
69
|
|
56
70
|
# Creates the dynamic menu lists.
|
@@ -82,6 +96,16 @@ def create_menu_lists
|
|
82
96
|
title: 'Puppet Functions',
|
83
97
|
search_title: 'Puppet Functions'
|
84
98
|
},
|
99
|
+
{
|
100
|
+
type: 'puppet_task',
|
101
|
+
title: 'Puppet Tasks',
|
102
|
+
search_totle: 'Puppet Tasks'
|
103
|
+
},
|
104
|
+
{
|
105
|
+
type: 'puppet_plan',
|
106
|
+
title: 'Puppet Plans',
|
107
|
+
search_totle: 'Puppet Plans'
|
108
|
+
},
|
85
109
|
{
|
86
110
|
type: 'class',
|
87
111
|
title: 'Ruby Classes',
|
@@ -163,6 +187,22 @@ def functions
|
|
163
187
|
erb(:objects)
|
164
188
|
end
|
165
189
|
|
190
|
+
# Renders the tasks section.
|
191
|
+
# @return [String] Returns the rendered section.
|
192
|
+
def tasks
|
193
|
+
@title = 'Puppet Task Listing A-Z'
|
194
|
+
@objects_by_letter = objects_by_letter(:puppet_task)
|
195
|
+
erb(:objects)
|
196
|
+
end
|
197
|
+
|
198
|
+
# Renders the plans section.
|
199
|
+
# @return [String] Returns the rendered section.
|
200
|
+
def plans
|
201
|
+
@title = 'Puppet Plan Listing A-Z'
|
202
|
+
@objects_by_letter = objects_by_letter(:puppet_plan)
|
203
|
+
erb(:objects)
|
204
|
+
end
|
205
|
+
|
166
206
|
# Renders the objects section.
|
167
207
|
# @return [String] Returns the rendered section.
|
168
208
|
def objects
|