puppet-strings 4.0.0 → 4.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d62acfc0a3e4fa9561fc3d3291a70335101c9705697b7736c17eb270547a0c2e
4
- data.tar.gz: 81606aea417506c5e2d3041d042df2b8a5299b08d6cf517993fe92019bd3b9ec
3
+ metadata.gz: d98415d18e6f6fcb4b755c59f2dc8c892c960531e4512b502413c99c8beba67d
4
+ data.tar.gz: a4043477cf9cfd60f87c3d78d4f21aa83e5a0074302ccc8529e66196370ba1d2
5
5
  SHA512:
6
- metadata.gz: 261ed46f4fd0da48e210942d6d61b3bbac7dc6e1bb3fabe101a30651b3cb0377e0864ed9f4ff7ebbea477a288ef6e09f477bca366cfd71564b74eda6a60c7d86
7
- data.tar.gz: 2aa3781199b8cb71bf9356c92a83df920d433fe07917c80ad500db8c16a54bcbf21ada74fcd41d4a063c6bad6ab9a874e830b4bde82ccfb4170749b31b6f6ba8
6
+ metadata.gz: 2663db3f7445b2af64a87edf6f579fd59f12b3e7fcb361333d810ded071b120245c0b1580033f3a68ea8386db58711090c12db0eb19ce6fb2295d60330f3f4af
7
+ data.tar.gz: 12de86d5a04659a5bfcaf6f690ea54aab2d77f47da06789acce5d65f91530a674e256437d70da6736fef3d663b390c89ee9b26c0972e2690740db8fb54f04584
data/CHANGELOG.md CHANGED
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
 
6
6
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
7
7
 
8
+ ## [v4.1.0](https://github.com/puppetlabs/puppet-strings/tree/v4.1.0) - 2023-07-04
9
+
10
+ [Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/v4.0.0...v4.1.0)
11
+
12
+ ### Added
13
+
14
+ - (CONT-1193) - Add `--providers` and `--list-providers` flags [#357](https://github.com/puppetlabs/puppet-strings/pull/357) ([jordanbreen28](https://github.com/jordanbreen28))
15
+
8
16
  ## [v4.0.0](https://github.com/puppetlabs/puppet-strings/tree/v4.0.0) - 2023-04-25
9
17
 
10
18
  [Full Changelog](https://github.com/puppetlabs/puppet-strings/compare/v4.0.0.rc.1...v4.0.0)
data/README.md CHANGED
@@ -107,7 +107,7 @@ An example of running the acceptance tests locally with Docker:
107
107
  4. Install test items; Puppet Agent, our test module, and the puppet-strings gem built from this source code
108
108
 
109
109
  ``` bash
110
- bundle exec rake 'litmus:install_agent[puppet6]'
110
+ bundle exec rake 'litmus:install_agent[puppet8]'
111
111
  bundle exec rake 'litmus:install_modules_from_directory[./spec/fixtures/acceptance/modules]'
112
112
  bundle exec rake litmus:install_gems
113
113
  ```
@@ -3,7 +3,7 @@
3
3
  require 'puppet/face'
4
4
 
5
5
  # Implements the 'puppet strings' interface.
6
- Puppet::Face.define(:strings, '0.0.1') do
6
+ Puppet::Face.define(:strings, '0.0.1') do # rubocop:disable Metrics/BlockLength
7
7
  summary 'Generate Puppet documentation with YARD.'
8
8
 
9
9
  action(:generate) do
@@ -83,7 +83,10 @@ Puppet::Face.define(:strings, '0.0.1') do
83
83
  summary 'list types'
84
84
  end
85
85
  option '--providers' do
86
- summary 'provide details on providers'
86
+ summary 'provide details on providers for each type'
87
+ end
88
+ option '--list-providers' do
89
+ summary 'list all providers'
87
90
  end
88
91
 
89
92
  # TODO: Implement the rest of describe behavior
@@ -96,6 +99,9 @@ Puppet::Face.define(:strings, '0.0.1') do
96
99
  # * --list:
97
100
  # List all types
98
101
 
102
+ # * --list-providers:
103
+ # list all providers
104
+
99
105
  # * --meta:
100
106
  # List all metaparameters
101
107
 
@@ -160,6 +166,8 @@ Puppet::Face.define(:strings, '0.0.1') do
160
166
  generate_options[:describe] = true
161
167
  generate_options[:describe_types] = options[:describe_types]
162
168
  generate_options[:describe_list] = options[:list]
169
+ generate_options[:providers] = options[:providers]
170
+ generate_options[:list_providers] = options[:list_providers]
163
171
  end
164
172
 
165
173
  format = options[:format]
@@ -7,31 +7,38 @@ require 'puppet-strings/json'
7
7
  module PuppetStrings::Describe
8
8
  # Renders requested types or a summarized list in the current YARD registry to STDOUT.
9
9
  # @param [Array] describe_types The list of names of the types to be displayed.
10
- # @param [bool] list Create the summarized list instead of describing each type.
11
- # @param [bool] _providers Show details of the providers.
10
+ # @param [bool] list_types Create the summarized list instead of describing each type.
11
+ # @param [bool] show_type_providers Show details of the providers of a specified type.
12
+ # @param [bool] list_providers Create a summarized list of providers.
12
13
  # @return [void]
13
- def self.render(describe_types = [], list = false, _providers = false)
14
+ def self.render(describe_types = [], list_types = false, show_type_providers = true, list_providers = false)
14
15
  document = {
15
16
  defined_types: YARD::Registry.all(:puppet_defined_type).sort_by!(&:name).map!(&:to_hash),
16
- resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash)
17
+ resource_types: YARD::Registry.all(:puppet_type).sort_by!(&:name).map!(&:to_hash),
18
+ providers: YARD::Registry.all(:puppet_provider).sort_by!(&:name).map!(&:to_hash)
17
19
  }
18
-
19
- if list
20
+ # if --list flag passed, produce a summarized list of types
21
+ if list_types
20
22
  puts 'These are the types known to puppet:'
21
- document[:resource_types].each { |t| list_one_type(t) }
22
- else
23
- document[:providers] = YARD::Registry.all(:puppet_provider).sort_by!(&:name).map!(&:to_hash)
23
+ document[:resource_types].each { |t| list_one(t) }
24
24
 
25
+ # if a type(s) has been passed, show the details of that type(s)
26
+ elsif describe_types
25
27
  type_names = {}
26
28
  describe_types.each { |name| type_names[name] = true }
27
29
 
28
30
  document[:resource_types].each do |t|
29
- show_one_type(t) if type_names[t[:name].to_s]
31
+ show_one_type(t, show_type_providers) if type_names[t[:name].to_s]
30
32
  end
33
+
34
+ # if --providers flag passed, produce a summarized list of providers
35
+ elsif list_providers
36
+ puts 'These are the providers known to puppet:'
37
+ document[:providers].each { |t| list_one(t) }
31
38
  end
32
39
  end
33
40
 
34
- def self.show_one_type(resource_type)
41
+ def self.show_one_type(resource_type, providers = true)
35
42
  puts format("\n%<name>s\n%<underscore>s", name: resource_type[:name], underscore: '=' * resource_type[:name].length)
36
43
  puts resource_type[:docstring][:text]
37
44
 
@@ -42,8 +49,10 @@ module PuppetStrings::Describe
42
49
 
43
50
  puts "\nParameters\n----------"
44
51
  combined_list.sort_by { |p| p[:name] }.each { |p| show_one_parameter(p) }
52
+ return unless providers
53
+
45
54
  puts "\nProviders\n---------"
46
- # Show providers here - list or provide details
55
+ resource_type[:providers]&.sort_by { |p| p[:name] }&.each { |p| puts p[:name].to_s.ljust(15) }
47
56
  end
48
57
 
49
58
  def self.show_one_parameter(parameter)
@@ -53,14 +62,14 @@ module PuppetStrings::Describe
53
62
  puts format('Requires features %<required_features>s.', required_features: parameter[:required_features]) unless parameter[:required_features].nil?
54
63
  end
55
64
 
56
- def self.list_one_type(type)
65
+ def self.list_one(object)
57
66
  targetlength = 48
58
67
  shortento = targetlength - 4
59
- contentstring = type[:docstring][:text]
68
+ contentstring = object[:docstring][:text]
60
69
  end_of_line = contentstring.index("\n") # "." gives closer results to old describeb, but breaks for '.k5login'
61
70
  contentstring = contentstring[0..end_of_line] unless end_of_line.nil?
62
71
  contentstring = "#{contentstring[0..shortento]} ..." if contentstring.length > targetlength
63
72
 
64
- puts "#{type[:name].to_s.ljust(15)} - #{contentstring}"
73
+ puts "#{object[:name].to_s.ljust(15)} - #{contentstring}"
65
74
  end
66
75
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetStrings
4
- VERSION = '4.0.0'
4
+ VERSION = '4.1.0'
5
5
  end
@@ -322,7 +322,7 @@ class PuppetStrings::Yard::Handlers::Ruby::FunctionHandler < PuppetStrings::Yard
322
322
  end
323
323
 
324
324
  type ||= tag&.types ? tag.type : 'Any'
325
- type = optional ? "Optional[#{type}]" : type
325
+ type = "Optional[#{type}]" if optional
326
326
 
327
327
  object.parameters << [name, to_puppet_literal(default)]
328
328
 
@@ -55,7 +55,7 @@ module PuppetStrings
55
55
 
56
56
  return unless options[:describe]
57
57
 
58
- render_describe(options[:describe_types], options[:describe_list], options[:providers])
58
+ render_describe(options[:describe_types], options[:describe_list], options[:providers], options[:list_providers])
59
59
  end
60
60
 
61
61
  def self.puppet_5?
@@ -72,9 +72,9 @@ module PuppetStrings
72
72
  PuppetStrings::Markdown.render(path)
73
73
  end
74
74
 
75
- def self.render_describe(describe_types, list = false, providers = false)
75
+ def self.render_describe(describe_types, list = false, show_providers = true, list_providers = false)
76
76
  require 'puppet-strings/describe'
77
- PuppetStrings::Describe.render(describe_types, list, providers)
77
+ PuppetStrings::Describe.render(describe_types, list, show_providers, list_providers)
78
78
  end
79
79
 
80
80
  # Runs the YARD documentation server.
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.0.0
4
+ version: 4.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-25 00:00:00.000000000 Z
11
+ date: 2023-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rgen