From 67d3f40df3c0b1006a6cb352ee2c33ff6ca56ea1 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 22 Jul 2024 15:20:33 -0700 Subject: [PATCH 1/3] Use --format and --out flags puppet-strings removed the deprecated `emit_*` flags, so use the modern replacements. See https://github.com/puppetlabs/puppet-strings/pull/329 --- lib/puppet_references/puppet/strings.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_references/puppet/strings.rb b/lib/puppet_references/puppet/strings.rb index bd1d37f9e9..972614ecde 100644 --- a/lib/puppet_references/puppet/strings.rb +++ b/lib/puppet_references/puppet/strings.rb @@ -23,7 +23,7 @@ def initialize(force_cached = false) def generate_strings_data puts 'Generating Puppet Strings JSON data...' rubyfiles = Dir.glob("#{PuppetReferences::PUPPET_DIR}/lib/puppet/**/*.rb") - system("bundle exec puppet strings generate --emit-json #{STRINGS_JSON_FILE} #{rubyfiles.join(' ')}") + system("bundle exec puppet strings generate --format json --out #{STRINGS_JSON_FILE} #{rubyfiles.join(' ')}") puts "Strings data: Done! (#{STRINGS_JSON_FILE})" @@strings_data_cached = true end From 15761686faf02f84793c7e7639ccbf7038e4e6c2 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 22 Jul 2024 15:24:20 -0700 Subject: [PATCH 2/3] Protect against docstring or tags being nil Previously, a NoMethodError could occur if either `signature['docstring']` or `signature['docstring']['tags']` returned nil. Now use ruby's dig and safenav operator. --- lib/puppet_references/puppet/functions_template.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_references/puppet/functions_template.erb b/lib/puppet_references/puppet/functions_template.erb index 7812434b2c..53b2320bc1 100644 --- a/lib/puppet_references/puppet/functions_template.erb +++ b/lib/puppet_references/puppet/functions_template.erb @@ -13,7 +13,7 @@ Signature <%= index+1 %> <% end -%> `<%= signature['signature'] %>` -<% has_parameters = signature['docstring']['tags'].detect {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil } +<% has_parameters = signature.dig('docstring', 'tags')&.detect {|tag| tag['tag_name'] == 'param' && tag['text'] != '' && tag['text'] != nil } || false if has_parameters -%> ### Parameters From b826a0db40b144b59eea825621189f77401f7365 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Mon, 22 Jul 2024 15:27:20 -0700 Subject: [PATCH 3/3] Update gem dependencies to allow puppet 7 or 8 The Gemfile was pinned to puppet 6.x, which has an incompatibility with concurrent-ruby: $ bundle exec rake references:puppet VERSION=8.7.0 ... Type ref: Done! Type ref: Building all... Generating Puppet Strings JSON data... bundler: failed to load command: puppet (/home/josh/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/bin/puppet) /home/josh/.rbenv/versions/3.1.1/lib/ruby/gems/3.1.0/gems/puppet-6.28.0/lib/puppet/thread_local.rb:6:in `': uninitialized constant Concurrent::RubyThreadLocalVar (NameError) Relax the Gemfile to allow either puppet 7 or 8 and update the Gemfile.lock --- Gemfile | 2 +- Gemfile.lock | 152 ++++++++++++++++++++++++--------------------------- 2 files changed, 73 insertions(+), 81 deletions(-) diff --git a/Gemfile b/Gemfile index 32a1abee9d..ba353148e4 100644 --- a/Gemfile +++ b/Gemfile @@ -21,7 +21,7 @@ group(:generate_references) do gem 'rgen', '~> 0.8' gem 'pandoc-ruby' gem 'puppet-strings' - gem 'puppet', '~> 6' + gem 'puppet', '>= 7', '< 9' gem 'nokogiri', '>= 1.12.5' gem 'pragmatic_segmenter', '~> 0.3' gem 'punkt-segmenter', '~> 0.9' diff --git a/Gemfile.lock b/Gemfile.lock index a376459598..9dacbb77b6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,44 +6,47 @@ PATH GEM remote: https://rubygems.org/ specs: - CFPropertyList (2.3.6) - activemodel (6.1.7) - activesupport (= 6.1.7) - activerecord (6.1.7) - activemodel (= 6.1.7) - activesupport (= 6.1.7) - activesupport (6.1.7) + activemodel (6.1.7.8) + activesupport (= 6.1.7.8) + activerecord (6.1.7.8) + activemodel (= 6.1.7.8) + activesupport (= 6.1.7.8) + activesupport (6.1.7.8) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 1.6, < 2) minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) - addressable (2.8.1) - public_suffix (>= 2.0.2, < 6.0) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + bigdecimal (3.1.8) blockenspiel (0.5.0) colorator (1.1.0) - concurrent-ruby (1.1.10) + concurrent-ruby (1.3.3) deep_merge (1.2.2) em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) eventmachine (1.2.7) - facter (4.2.13) + facter (4.7.1) hocon (~> 1.3) - thor (>= 1.0.1, < 2.0) - fast_gettext (1.8.0) - ffi (1.15.5) + thor (>= 1.0.1, < 1.3) + fast_gettext (2.4.0) + prime + ffi (1.17.0-x86_64-linux-gnu) + forwardable (1.3.3) forwardable-extended (2.6.0) - git (1.12.0) + git (1.19.1) addressable (~> 2.8) rchardet (~> 1.8) - hiera (3.10.0) - hocon (1.3.1) + google-protobuf (4.27.2-x86_64-linux) + bigdecimal + rake (>= 13) + hocon (1.4.0) http_parser.rb (0.8.0) - httpclient (2.8.3) - i18n (1.12.0) + i18n (1.14.5) concurrent-ruby (~> 1.0) - jekyll (4.3.1) + jekyll (4.3.3) addressable (~> 2.4) colorator (~> 1.0) em-websocket (~> 0.5) @@ -59,96 +62,87 @@ GEM safe_yaml (~> 1.0) terminal-table (>= 1.8, < 4.0) webrick (~> 1.7) - jekyll-sass-converter (2.2.0) - sassc (> 2.0.1, < 3.0) + jekyll-sass-converter (3.0.0) + sass-embedded (~> 1.54) jekyll-watch (2.2.1) listen (~> 3.0) - json (2.6.2) + json (2.7.2) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - liquid (4.0.3) + liquid (4.0.4) listen (3.5.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - locale (2.1.3) + locale (2.1.4) maruku (0.7.3) mercenary (0.4.0) - mini_portile2 (2.8.0) - minitest (5.16.3) + minitest (5.24.1) multi_json (1.15.0) - nokogiri (1.13.9) - mini_portile2 (~> 2.8.0) - racc (~> 1.4) - nokogiri (1.13.9-x86_64-darwin) + nokogiri (1.16.6-x86_64-linux) racc (~> 1.4) open4 (1.3.4) - pandoc-ruby (2.1.7) + pandoc-ruby (2.1.10) pathutil (0.16.2) forwardable-extended (~> 2.6) pragmatic_segmenter (0.3.23) unicode - psych (4.0.6) + prime (0.1.2) + forwardable + singleton + psych (5.1.2) stringio - public_suffix (5.0.0) + public_suffix (6.0.0) punkt-segmenter (0.9.1) unicode_utils (>= 1.0.0) - puppet (6.28.0) - concurrent-ruby (~> 1.0) - deep_merge (~> 1.0) - facter (> 2.0.1, < 5) - fast_gettext (~> 1.1) - hiera (>= 3.2.1, < 4) - httpclient (~> 2.8) - locale (~> 2.1) - multi_json (~> 1.10) - puppet-resource_api (~> 1.5) - semantic_puppet (~> 1.0) - puppet (6.28.0-universal-darwin) - CFPropertyList (~> 2.2) + puppet (8.7.0) concurrent-ruby (~> 1.0) deep_merge (~> 1.0) - facter (> 2.0.1, < 5) - fast_gettext (~> 1.1) - hiera (>= 3.2.1, < 4) - httpclient (~> 2.8) + facter (>= 4.3.0, < 5) + fast_gettext (>= 2.1, < 3) locale (~> 2.1) - multi_json (~> 1.10) + multi_json (~> 1.13) puppet-resource_api (~> 1.5) + scanf (~> 1.0) semantic_puppet (~> 1.0) - puppet-resource_api (1.8.14) + puppet-resource_api (1.9.0) hocon (>= 1.0) - puppet-strings (2.9.0) - rgen - yard (~> 0.9.5) - racc (1.6.0) - rack (2.2.4) - rake (13.0.6) + puppet-strings (4.1.2) + rgen (~> 0.9) + yard (~> 0.9) + racc (1.8.0) + rack (2.2.9) + rake (13.2.1) rake-remote_task (2.4.4) open4 (~> 1.0) rake (>= 0.8, < 15.0) rb-fsevent (0.11.2) - rb-inotify (0.10.1) + rb-inotify (0.11.1) ffi (~> 1.0) rchardet (1.8.0) - rdoc (6.4.0) + rdoc (6.7.0) psych (>= 4.0.0) - rexml (3.2.5) - rgen (0.9.0) - rouge (3.30.0) + rexml (3.3.2) + strscan + rgen (0.9.1) + rouge (4.3.0) safe_yaml (1.0.5) - sassc (2.4.0) - ffi (~> 1.9) - semantic_puppet (1.0.4) - stringio (3.0.2) + sass-embedded (1.77.8) + google-protobuf (~> 4.26) + rake (>= 13) + scanf (1.0.0) + semantic_puppet (1.1.0) + singleton (0.2.0) + stringio (3.1.1) + strscan (3.1.0) terminal-table (3.0.2) unicode-display_width (>= 1.1.1, < 3) - thor (1.2.1) - tzinfo (2.0.5) + thor (1.2.2) + tzinfo (2.0.6) concurrent-ruby (~> 1.0) - unicode (0.4.4.4) - unicode-display_width (2.3.0) + unicode (0.4.4.5) + unicode-display_width (2.5.0) unicode_utils (1.4.0) versionomy (0.5.0) blockenspiel (~> 0.5) @@ -157,14 +151,12 @@ GEM rake-remote_task (~> 2.3) vlad-git (2.2.0) vlad (>= 2.1.0) - webrick (1.7.0) - yard (0.9.28) - webrick (~> 1.7.0) - zeitwerk (2.6.6) + webrick (1.8.1) + yard (0.9.36) + zeitwerk (2.6.16) PLATFORMS - ruby - x86_64-darwin-18 + x86_64-linux DEPENDENCIES activerecord (~> 6) @@ -178,7 +170,7 @@ DEPENDENCIES pandoc-ruby pragmatic_segmenter (~> 0.3) punkt-segmenter (~> 0.9) - puppet (~> 6) + puppet (>= 7, < 9) puppet-strings puppet_docs! rack (~> 2.2, >= 2.2.3) @@ -191,4 +183,4 @@ DEPENDENCIES yard (~> 0.9) BUNDLED WITH - 2.2.14 + 2.5.10