2014-05-16 17:54:34 +00:00
|
|
|
require 'puppet/face'
|
|
|
|
|
|
|
|
Puppet::Face.define(:yardoc, '0.0.1') do
|
2014-06-01 06:24:27 +00:00
|
|
|
summary "Generate Puppet documentation with YARD."
|
2014-05-16 17:54:34 +00:00
|
|
|
|
|
|
|
action(:yardoc) do
|
|
|
|
default
|
|
|
|
|
2014-06-01 06:24:27 +00:00
|
|
|
summary "Generate module documentation."
|
|
|
|
arguments "[manifest_file.pp ...]"
|
|
|
|
|
2014-05-26 19:02:59 +00:00
|
|
|
when_invoked do |*args|
|
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
|
|
|
|
|
2014-05-24 19:54:22 +00:00
|
|
|
unless Puppet.features.rgen?
|
2014-05-20 05:24:03 +00:00
|
|
|
raise RuntimeError, "The 'rgen' gem must be installed in order to use this face."
|
|
|
|
end
|
|
|
|
|
2014-05-30 16:59:55 +00:00
|
|
|
if RUBY_VERSION < '1.9' && !Puppet.features.require_relative?
|
|
|
|
raise RuntimeError, "The 'backports' gem must be installed in order to use this face under Ruby 1.8.7."
|
|
|
|
end
|
|
|
|
|
2014-05-26 19:02:59 +00:00
|
|
|
# The last element of the argument array should be the options hash.
|
|
|
|
#
|
|
|
|
# NOTE: The Puppet Face will throw 'unrecognized option' errors if any
|
|
|
|
# YARD options are passed to it. The best way to approach this problem is
|
|
|
|
# by using the `.yardopts` file. YARD will autoload any options placed in
|
|
|
|
# that file.
|
|
|
|
opts = args.pop
|
|
|
|
|
|
|
|
# For now, assume the remaining positional args are a list of manifest
|
|
|
|
# files to parse.
|
|
|
|
manifest_files = (args.empty? ? ['manifests/**/*.pp'] : args)
|
|
|
|
|
2014-05-24 19:54:22 +00:00
|
|
|
require 'puppetx/yardoc/yard/plugin'
|
|
|
|
|
2014-05-26 02:14:52 +00:00
|
|
|
# Hand off to YARD for further processing.
|
2014-05-26 19:02:59 +00:00
|
|
|
YARD::CLI::Yardoc.run(*manifest_files)
|
2014-05-16 17:54:34 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|