From: Brice Figureau <[email protected]>

class klass {
  include a, b, c
}

wasn't producing any rdoc documentation.
We were thinking code was always embedded in an array which is not
the case for mono-instruction code.

Signed-off-by: Brice Figureau <[email protected]>
Signed-off-by: James Turnbull <[email protected]>
---
 lib/puppet/util/rdoc/parser.rb |    3 +++
 spec/unit/util/rdoc/parser.rb  |   18 ++++++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index aa34335..d7e1c30 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -148,6 +148,7 @@ class Parser
     # create documentation for include statements we can find in +code+
     # and associate it with +container+
     def scan_for_include_or_require(container, code)
+        code = [code] unless code.is_a?(Array)
         code.each do |stmt|
             scan_for_include_or_require(container,stmt.children) if 
stmt.is_a?(Puppet::Parser::AST::ASTArray)
 
@@ -163,6 +164,7 @@ class Parser
     # create documentation for global variables assignements we can find in 
+code+
     # and associate it with +container+
     def scan_for_vardef(container, code)
+        code = [code] unless code.is_a?(Array)
         code.each do |stmt|
             scan_for_vardef(container,stmt.children) if 
stmt.is_a?(Puppet::Parser::AST::ASTArray)
 
@@ -176,6 +178,7 @@ class Parser
     # create documentation for resources we can find in +code+
     # and associate it with +container+
     def scan_for_resource(container, code)
+        code = [code] unless code.is_a?(Array)
         code.each do |stmt|
             scan_for_resource(container,stmt.children) if 
stmt.is_a?(Puppet::Parser::AST::ASTArray)
 
diff --git a/spec/unit/util/rdoc/parser.rb b/spec/unit/util/rdoc/parser.rb
index b05df6d..de11832 100755
--- a/spec/unit/util/rdoc/parser.rb
+++ b/spec/unit/util/rdoc/parser.rb
@@ -321,6 +321,12 @@ describe RDoc::Parser do
             
@code.stubs(:is_a?).with(Puppet::Parser::AST::ASTArray).returns(true)
         end
 
+        it "should also scan mono-instruction code" do
+            @class.expects(:add_include).with { |i| i.is_a?(RDoc::Include) and 
i.name == "myclass" and i.comment == "mydoc" }
+
+            @parser.scan_for_include_or_require(@class,create_stmt("include"))
+        end
+
         it "should register recursively includes to the current container" do
             @code.stubs(:children).returns([ create_stmt("include") ])
 
@@ -354,6 +360,12 @@ describe RDoc::Parser do
             @class.expects(:add_constant).with { |i| i.is_a?(RDoc::Constant) 
and i.name == "myvar" and i.comment == "mydoc" }
             @parser.scan_for_vardef(@class, [ @code ])
         end
+
+        it "should also scan mono-instruction code" do
+            @class.expects(:add_constant).with { |i| i.is_a?(RDoc::Constant) 
and i.name == "myvar" and i.comment == "mydoc" }
+
+            @parser.scan_for_vardef(@class, @stmt)
+        end
     end
 
     describe "when scanning for resources" do
@@ -375,6 +387,12 @@ describe RDoc::Parser do
             @class.expects(:add_resource).with { |i| 
i.is_a?(RDoc::PuppetResource) and i.title == "myfile" and i.comment == "mydoc" }
             @parser.scan_for_resource(@class, [ @code ])
         end
+
+        it "should also scan mono-instruction code" do
+            @class.expects(:add_resource).with { |i| 
i.is_a?(RDoc::PuppetResource) and i.title == "myfile" and i.comment == "mydoc" }
+
+            @parser.scan_for_resource(@class, @stmt)
+        end
     end
 
     describe "when parsing plugins" do
-- 
1.6.5.2

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.


Reply via email to