summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/lexer.rb22
-rw-r--r--lib/puppet/parser/parser_support.rb2
2 files changed, 15 insertions, 9 deletions
diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
index e296872f9..5bab6d65d 100644
--- a/lib/puppet/parser/lexer.rb
+++ b/lib/puppet/parser/lexer.rb
@@ -332,7 +332,7 @@ class Puppet::Parser::Lexer
@namestack = []
@indefine = false
@expected = []
- @commentstack = ['']
+ @commentstack = [ ['', @line] ]
end
# Make any necessary changes to the token and/or value.
@@ -348,7 +348,9 @@ class Puppet::Parser::Lexer
return unless token
if token.accumulate?
- @commentstack.last << value + "\n"
+ comment = @commentstack.pop
+ comment[0] << value + "\n"
+ @commentstack.push(comment)
end
return if token.skip
@@ -490,16 +492,20 @@ class Puppet::Parser::Lexer
# returns the content of the currently accumulated content cache
def commentpop
- return @commentstack.pop
+ return @commentstack.pop[0]
end
- def getcomment
- comment = @commentstack.pop
- @commentstack.push('')
- return comment
+ def getcomment(line = nil)
+ comment = @commentstack.last
+ if line.nil? or comment[1] <= line
+ @commentstack.pop
+ @commentstack.push(['', @line])
+ return comment[0]
+ end
+ return ''
end
def commentpush
- @commentstack.push('')
+ @commentstack.push(['', @line])
end
end
diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb
index 92db9af5f..e1af2fe82 100644
--- a/lib/puppet/parser/parser_support.rb
+++ b/lib/puppet/parser/parser_support.rb
@@ -50,7 +50,7 @@ class Puppet::Parser::Parser
end
k = klass.new(hash)
- k.doc = lexer.getcomment if !k.nil? and k.use_docs and k.doc.empty?
+ k.doc = lexer.getcomment(hash[:line]) if !k.nil? and k.use_docs and k.doc.empty?
return k
end