diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-11-10 18:19:59 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-11-12 08:02:10 +1100 |
commit | 38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df (patch) | |
tree | 7df4540de585f8775d219a5e6c459f21ac77fc10 /lib/puppet | |
parent | 5f7177efeae81c86086d73b3c7869302cfc6a40d (diff) | |
download | puppet-38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df.tar.gz puppet-38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df.tar.xz puppet-38ec9fcc5f3965942a74c8d7b7dfd1cf1796c0df.zip |
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 <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parser/ast/leaf.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/resourceparam.rb | 4 | ||||
-rw-r--r-- | lib/puppet/parser/ast/selector.rb | 4 | ||||
-rw-r--r-- | lib/puppet/util/rdoc/parser.rb | 9 |
4 files changed, 18 insertions, 3 deletions
diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb index 153120a34..b73c781e1 100644 --- a/lib/puppet/parser/ast/leaf.rb +++ b/lib/puppet/parser/ast/leaf.rb @@ -150,6 +150,10 @@ class Puppet::Parser::AST return scope.lookupvar(@value) end end + + def to_s + "\$#{value}" + end end class Regex < AST::Leaf diff --git a/lib/puppet/parser/ast/resourceparam.rb b/lib/puppet/parser/ast/resourceparam.rb index c552a7ee5..e6d9df17f 100644 --- a/lib/puppet/parser/ast/resourceparam.rb +++ b/lib/puppet/parser/ast/resourceparam.rb @@ -18,5 +18,9 @@ class Puppet::Parser::AST :add => self.add ) end + + def to_s + "#{@param} => #{@value.to_s}" + end end end diff --git a/lib/puppet/parser/ast/selector.rb b/lib/puppet/parser/ast/selector.rb index 1b05f57f0..84bc2a74a 100644 --- a/lib/puppet/parser/ast/selector.rb +++ b/lib/puppet/parser/ast/selector.rb @@ -41,5 +41,9 @@ class Puppet::Parser::AST ensure scope.unset_ephemeral_var end + + def to_s + param.to_s + " ? { " + values.collect { |v| v.to_s }.join(', ') + " }" + end end end 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 << ", " |