summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-11-10 18:19:59 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-11-12 08:08:04 +1100
commit53be6f81261db1b7a022ec683e1a637cd2c5c93e (patch)
tree3bca7ea658e44d09dd989f0ef1047b570708ab8a /lib/puppet/parser
parent391786f0b43e514d58336f465bc53fb7a5c34884 (diff)
downloadpuppet-53be6f81261db1b7a022ec683e1a637cd2c5c93e.tar.gz
puppet-53be6f81261db1b7a022ec683e1a637cd2c5c93e.tar.xz
puppet-53be6f81261db1b7a022ec683e1a637cd2c5c93e.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/parser')
-rw-r--r--lib/puppet/parser/ast/leaf.rb4
-rw-r--r--lib/puppet/parser/ast/resourceparam.rb4
-rw-r--r--lib/puppet/parser/ast/selector.rb4
3 files changed, 12 insertions, 0 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