diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2008-11-15 13:10:55 +0100 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-11-17 21:05:36 +1100 |
commit | 064fb006a350e9555abe766c5cb4aeb803fd623a (patch) | |
tree | e9dd550404cb84a4a9c11d08560c9408bbba6f40 /lib/puppet/parser/ast.rb | |
parent | 724a6f672308ab6f52d738caf20c5994e6225071 (diff) | |
download | puppet-064fb006a350e9555abe766c5cb4aeb803fd623a.tar.gz puppet-064fb006a350e9555abe766c5cb4aeb803fd623a.tar.xz puppet-064fb006a350e9555abe766c5cb4aeb803fd623a.zip |
Add a doc attribute to AST nodes and fill it with the last seen comments
The lexer maintains a stack of last seen comments.
On blank lines the lexer flush the comments.
On each opening brace the lexer enters a new stack level.
On each block AST nodes, the stack is popped.
Each AST nodes has a doc property that is filled with the
last seen comments on node creation (in fact only on important node
creation representing statements).
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/parser/ast.rb')
-rw-r--r-- | lib/puppet/parser/ast.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index ddf88521c..303d75bac 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -12,8 +12,23 @@ class Puppet::Parser::AST include Puppet::Util::Errors include Puppet::Util::MethodHelper + include Puppet::Util::Docs + attr_accessor :line, :file, :parent, :scope + # don't fetch lexer comment by default + def use_docs + self.class.use_docs + end + + # allow our subclass to specify they want documentation + class << self + attr_accessor :use_docs + def associates_doc + self.use_docs = true + end + end + # Does this ast object set something? If so, it gets evaluated first. def self.settor? if defined? @settor |