2014-05-16 17:54:34 +00:00
|
|
|
require 'puppet/face'
|
2014-05-22 05:14:53 +00:00
|
|
|
require 'puppetx/yardoc/util'
|
2014-05-16 17:54:34 +00:00
|
|
|
|
|
|
|
Puppet::Face.define(:yardoc, '0.0.1') do
|
|
|
|
|
|
|
|
action(:yardoc) do
|
|
|
|
default
|
|
|
|
|
2014-05-22 05:14:53 +00:00
|
|
|
when_invoked do |manifest, options|
|
2014-05-20 05:24:03 +00:00
|
|
|
|
|
|
|
unless Puppet.features.yard?
|
|
|
|
raise RuntimeError, "The 'yard' gem must be installed in order to use this face."
|
|
|
|
end
|
|
|
|
|
|
|
|
if Puppet.features.rgen?
|
|
|
|
require 'puppet/pops'
|
|
|
|
else
|
|
|
|
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face."
|
|
|
|
end
|
|
|
|
|
2014-05-16 17:54:34 +00:00
|
|
|
parser = Puppet::Pops::Parser::Parser.new()
|
2014-05-22 05:14:53 +00:00
|
|
|
parse_result = parser.parse_file(manifest)
|
2014-05-16 17:54:34 +00:00
|
|
|
|
2014-05-22 05:14:53 +00:00
|
|
|
commentor = Puppetx::Yardoc::Commentor.new()
|
|
|
|
|
|
|
|
return commentor.get_comments(parse_result)
|
2014-05-16 17:54:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|