From b1deb89bae67f7d71ffe412ce4fd8e99c6e1c159 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 13 Oct 2009 23:31:54 +0200 Subject: Covers the RDoc Puppet Parser with specs This doesn't cover all the code, only the part that interacts with Puppet internals which is what matters when Puppet changes. This patch also contains an integration test. Signed-off-by: Brice Figureau --- lib/puppet/util/rdoc/parser.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb index 6d0e8f7cc..aa34335cc 100644 --- a/lib/puppet/util/rdoc/parser.rb +++ b/lib/puppet/util/rdoc/parser.rb @@ -15,6 +15,8 @@ module RDoc class Parser extend ParserFactory + attr_accessor :ast, :input_file_name, :top_level + # parser registration into RDoc parse_files_matching(/\.(rb|pp)$/) @@ -39,8 +41,6 @@ class Parser @top_level end - private - # Due to a bug in RDoc, we need to roll our own find_module_named # The issue is that RDoc tries harder by asking the parent for a class/module # of the name. But by doing so, it can mistakenly use a module of same name @@ -277,8 +277,8 @@ class Parser # register method into the container meth = AnyMethod.new(declaration, name) - container.add_method(meth) meth.comment = define.doc + container.add_method(meth) look_for_directives_in(container, meth.comment) unless meth.comment.empty? meth.params = "( " + declaration + " )" meth.visibility = :public @@ -296,7 +296,7 @@ class Parser unless name.empty? document_class(name,klass,container) else # on main class document vardefs - code = klass.code.children unless klass.code.is_a?(Puppet::Parser::AST::ASTArray) + code = klass.code.children if klass.code.is_a?(Puppet::Parser::AST::ASTArray) code ||= klass.code scan_for_vardef(container, code) unless code.nil? end @@ -337,9 +337,9 @@ class Parser comments += $1 + "\n" elsif line =~ /^[ \t]*Facter.add\(['"](.*?)['"]\)/ current_fact = Fact.new($1,{}) - container.add_fact(current_fact) look_for_directives_in(container, comments) unless comments.empty? current_fact.comment = comments + container.add_fact(current_fact) current_fact.record_location(@top_level) comments = "" Puppet.debug "rdoc: found custom fact %s" % current_fact.name -- cgit