summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util/rdoc/parser.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-11-10 17:57:26 +0100
committerJames Turnbull <james@lovedthanlost.net>2009-11-12 08:02:10 +1100
commit5f7177efeae81c86086d73b3c7869302cfc6a40d (patch)
tree279487b360774d86530acad82cda764c44debc3c /lib/puppet/util/rdoc/parser.rb
parent136949da70f1a6715734faa6ac3c464f386fccfb (diff)
downloadpuppet-5f7177efeae81c86086d73b3c7869302cfc6a40d.tar.gz
puppet-5f7177efeae81c86086d73b3c7869302cfc6a40d.tar.xz
puppet-5f7177efeae81c86086d73b3c7869302cfc6a40d.zip
Fix #2795 - puppetdoc rdoc reports a better error message
When puppetdoc rdoc dies with an unhandled exception, the error message produced didn't mention the file and line where the parser choked. This patch fixes this by trying to locate on which AST structure the rdoc system failed. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'lib/puppet/util/rdoc/parser.rb')
-rw-r--r--lib/puppet/util/rdoc/parser.rb36
1 files changed, 23 insertions, 13 deletions
diff --git a/lib/puppet/util/rdoc/parser.rb b/lib/puppet/util/rdoc/parser.rb
index 554f8cb00..2d219d19c 100644
--- a/lib/puppet/util/rdoc/parser.rb
+++ b/lib/puppet/util/rdoc/parser.rb
@@ -180,20 +180,24 @@ class Parser
scan_for_resource(container,stmt.children) if stmt.is_a?(Puppet::Parser::AST::ASTArray)
if stmt.is_a?(Puppet::Parser::AST::Resource) and !stmt.type.nil?
- type = stmt.type.split("::").collect { |s| s.capitalize }.join("::")
- title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s
- Puppet.debug "rdoc: found resource: %s[%s]" % [type,title]
-
- param = []
- stmt.params.children.each do |p|
- res = {}
- res["name"] = p.param
- res["value"] = "#{p.value.to_s}" unless p.value.nil?
-
- param << res
+ begin
+ type = stmt.type.split("::").collect { |s| s.capitalize }.join("::")
+ title = stmt.title.is_a?(Puppet::Parser::AST::ASTArray) ? stmt.title.to_s.gsub(/\[(.*)\]/,'\1') : stmt.title.to_s
+ Puppet.debug "rdoc: found resource: %s[%s]" % [type,title]
+
+ param = []
+ stmt.params.children.each do |p|
+ res = {}
+ res["name"] = p.param
+ res["value"] = "#{p.value.to_s}" unless p.value.nil?
+
+ param << res
+ end
+
+ container.add_resource(PuppetResource.new(type, title, stmt.doc, param))
+ rescue => detail
+ raise Puppet::ParseError, "impossible to parse resource in #{stmt.file} at line #{stmt.line}: #{detail}"
end
-
- container.add_resource(PuppetResource.new(type, title, stmt.doc, param))
end
end
end
@@ -225,6 +229,8 @@ class Parser
end
cls.comment = comment
+ rescue => detail
+ raise Puppet::ParseError, "impossible to parse class '#{name}' in #{klass.file} at line #{klass.line}: #{detail}"
end
# create documentation for a node
@@ -247,6 +253,8 @@ class Parser
end
n.comment = comment
+ rescue => detail
+ raise Puppet::ParseError, "impossible to parse node '#{name}' in #{node.file} at line #{node.line}: #{detail}"
end
# create documentation for a define
@@ -284,6 +292,8 @@ class Parser
meth.visibility = :public
meth.document_self = true
meth.singleton = false
+ rescue => detail
+ raise Puppet::ParseError, "impossible to parse definition '#{name}' in #{define.file} at line #{define.line}: #{detail}"
end
# Traverse the AST tree and produce code-objects node