From 38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 10 Nov 2009 18:19:59 +0100 Subject: Fix #2796 - Fix puppetdoc rdoc selector parsing This patch fix this bug by adding more to_s methods to ast member so that puppetdoc can just to_s the AST to reconstruct the original puppet code. Of course this is not perfect, but should work most of the time. Signed-off-by: Brice Figureau --- lib/puppet/util/rdoc/parser.rb | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/puppet/util') diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb index 2d219d19c..97a245a14 100644 --- a/lib/puppet/util/rdoc/parser.rb +++ b/lib/puppet/util/rdoc/parser.rb @@ -271,12 +271,15 @@ class Parser declaration = "" define.arguments.each do |arg,value| declaration << "\$#{arg}" - if !value.nil? + unless value.nil? declaration << " => " - if !value.is_a?(Puppet::Parser::AST::ASTArray) + case value + when Puppet::Parser::AST::Leaf declaration << "'#{value.value}'" - else + when Puppet::Parser::AST::ASTArray declaration << "[%s]" % value.children.collect { |v| "'#{v}'" }.join(", ") + else + declaration << "#{value.to_s}" end end declaration << ", " -- cgit