From 4dc6bc429a4a36ee202efe0259db7471b404a553 Mon Sep 17 00:00:00 2001 From: Ian Kronquist Date: Tue, 21 Jul 2015 15:15:30 -0700 Subject: [PATCH 1/2] (PDOC-35) Dispatch handlers in correct order Subclasses have their superclass as part of their namespace and objects in the subclass's namespace must be registered first. Reverse the list of parsed objects so that the classes will be handled and registered in the correct order. --- lib/puppet_x/puppetlabs/strings/yard/parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet_x/puppetlabs/strings/yard/parser.rb b/lib/puppet_x/puppetlabs/strings/yard/parser.rb index 7237425..630846d 100644 --- a/lib/puppet_x/puppetlabs/strings/yard/parser.rb +++ b/lib/puppet_x/puppetlabs/strings/yard/parser.rb @@ -24,7 +24,7 @@ class PuppetX::PuppetLabs::Strings::YARD::PuppetParser < YARD::Parser::Base statements = @transformer.transform(@parse_result) # Ensure an array is returned and prune any nil values. - Array(statements).compact + Array(statements).compact.reverse end end From 457ec86a2b08744bb0b9a03492c2b9d016073aa1 Mon Sep 17 00:00:00 2001 From: Ian Kronquist Date: Mon, 27 Jul 2015 11:13:53 -0700 Subject: [PATCH 2/2] (PDOC-35) Test strings works with nested classes --- .../test/manifests/triple_nested_classes.pp | 27 +++++++++++++++++ spec/unit/puppet/face_spec.rb | 30 +++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 spec/unit/puppet/examples/test/manifests/triple_nested_classes.pp diff --git a/spec/unit/puppet/examples/test/manifests/triple_nested_classes.pp b/spec/unit/puppet/examples/test/manifests/triple_nested_classes.pp new file mode 100644 index 0000000..6ac95cd --- /dev/null +++ b/spec/unit/puppet/examples/test/manifests/triple_nested_classes.pp @@ -0,0 +1,27 @@ +# Testing tested classes +# docs stuff +# @param nameservers [String] Don't ask me what this does! +# @param default_lease_time [Integer[1024, 8192]] text goes here +# @param max_lease_time does stuff +class outer ( + $dnsdomain, + $nameservers, + $default_lease_time = 3600, + $max_lease_time = 86400 + ) { + # @param options [String[5,7]] gives user choices + # @param multicast [Boolean] foobar + # @param servers yep, that's right + class middle ( + $options = "iburst", + $servers, + $multicast = false + ) { + class inner ( + $choices = "uburst", + $secenekler = "weallburst", + $boxen, + $manyspell = true + ) {} + } +} diff --git a/spec/unit/puppet/face_spec.rb b/spec/unit/puppet/face_spec.rb index 5119c41..015c051 100644 --- a/spec/unit/puppet/face_spec.rb +++ b/spec/unit/puppet/face_spec.rb @@ -79,6 +79,36 @@ describe Puppet::Face do expect(read_html(tmp, 'test', 'Puppet4xFunctions.html')).to include("This is a function which is used to test puppet strings") end end + + it "should create correct files for nested classes" do + using_module('test') do |tmp| + Dir.chdir('test') + + Puppet::Face[:strings, :current].yardoc + + expect(read_html(tmp, + 'test', 'outer.html')).to include("Puppet Class: outer") + expect(read_html(tmp, 'test', + 'outer/middle.html')).to include("Puppet Class: middle") + expect(read_html(tmp, 'test', + 'outer/middle/inner.html')).to include("Puppet Class: inner") + end + end + + it "should create proper namespace for nested classes" do + using_module('test') do |tmp| + Dir.chdir('test') + + Puppet::Face[:strings, :current].yardoc + + expect(read_html(tmp, + 'test', 'outer.html')).to include("Hostclass: outer") + expect(read_html(tmp, 'test', + 'outer/middle.html')).to include("Hostclass: outer::middle") + expect(read_html(tmp, 'test', + 'outer/middle/inner.html')).to include("Hostclass: outer::middle::inner") + end + end end end