[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5-303-gfcfa26a

Brice Figureau brice-puppet at daysofwonder.com
Thu Mar 17 10:46:11 UTC 2011


The following commit has been merged in the upstream branch:
commit b4a171e78c501208798220910352943331ceb9e0
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Fri Feb 11 22:46:15 2011 +0100

    Fix #5720 - puppetdoc misses some class comments
    
    It appears that the fix for #5252 wasn't complete, and class, nodes and
    definition were still using the current lexer line number instead of
    the line number of the class/define/node token.
    This combined with some missing comments stack pushing/pop on parenthesis
    prevented puppetdoc to correctly get the documentation of some class (including
    parametrized ones).
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index 31d39ae..9a25263 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -476,9 +476,12 @@ class Puppet::Parser::Lexer
         @expected.pop
       end
 
-      if final_token.name == :LBRACE
+      if final_token.name == :LBRACE or final_token.name == :LPAREN
         commentpush
       end
+      if final_token.name == :RPAREN
+        commentpop
+      end
 
       yield [final_token.name, token_value]
 
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index 7bbebb1..7a0aa26 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -135,19 +135,19 @@ class Puppet::Parser::Parser
 
   # Create a new class, or merge with an existing class.
   def newclass(name, options = {})
-    known_resource_types.add Puppet::Resource::Type.new(:hostclass, name, ast_context(true).merge(options))
+    known_resource_types.add Puppet::Resource::Type.new(:hostclass, name, ast_context(true, options[:line]).merge(options))
   end
 
   # Create a new definition.
   def newdefine(name, options = {})
-    known_resource_types.add Puppet::Resource::Type.new(:definition, name, ast_context(true).merge(options))
+    known_resource_types.add Puppet::Resource::Type.new(:definition, name, ast_context(true, options[:line]).merge(options))
   end
 
   # Create a new node.  Nodes are special, because they're stored in a global
   # table, not according to namespaces.
   def newnode(names, options = {})
     names = [names] unless names.instance_of?(Array)
-    context = ast_context(true)
+    context = ast_context(true, options[:line])
     names.collect do |name|
       known_resource_types.add(Puppet::Resource::Type.new(:node, name, context.merge(options)))
     end
diff --git a/spec/unit/parser/lexer_spec.rb b/spec/unit/parser/lexer_spec.rb
index 8603269..4ef242c 100755
--- a/spec/unit/parser/lexer_spec.rb
+++ b/spec/unit/parser/lexer_spec.rb
@@ -529,6 +529,22 @@ describe Puppet::Parser::Lexer, "when lexing comments" do
     @lexer.fullscan
   end
 
+  it "should add a new comment stack level on LPAREN" do
+    @lexer.string = "("
+
+    @lexer.expects(:commentpush)
+
+    @lexer.fullscan
+  end
+
+  it "should pop the current comment on RPAREN" do
+    @lexer.string = ")"
+
+    @lexer.expects(:commentpop)
+
+    @lexer.fullscan
+  end
+
   it "should return the current comments on getcomment" do
     @lexer.string = "# comment"
     @lexer.fullscan
diff --git a/spec/unit/parser/parser_spec.rb b/spec/unit/parser/parser_spec.rb
index 07e2d22..9aab6a7 100755
--- a/spec/unit/parser/parser_spec.rb
+++ b/spec/unit/parser/parser_spec.rb
@@ -304,6 +304,33 @@ describe Puppet::Parser do
     it "should return an array of nodes" do
       @parser.newnode(@nodename).should be_instance_of(Array)
     end
+
+    it "should initialize the ast context with the correct line number" do
+      @parser.expects(:ast_context).with { |a,b| b == 123 }.returns({})
+      @parser.newnode(@nodename, { :line => 123 })
+    end
+  end
+
+  %w{class define}.each do |entity|
+    describe "when creating a #{entity}" do
+      before :each do
+        @parser.stubs(:ast_context).returns({})
+
+        @name = stub "#{entity}name", :is_a? => false, :value => "foo"
+      end
+
+      it "should create and add the correct resource type" do
+        instance = stub 'instance'
+        Puppet::Resource::Type.expects(:new).returns(instance)
+        @parser.known_resource_types.expects(:add).with(instance)
+        @parser.send("new#{entity}", @name)
+      end
+
+      it "should initialize the ast context with the correct line number" do
+        @parser.expects(:ast_context).with { |a,b| b == 123 }.returns({})
+        @parser.send("new#{entity}", @name, { :line => 123 })
+      end
+    end
   end
 
   describe "when retrieving a specific node" do

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list