From 1b275a492659c5376da198032291d11d289cac0a Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Mon, 26 May 2014 12:02:59 -0700 Subject: [PATCH] Re-work yardoc options The `puppet yardoc` command now consumes an optional list of manifest files to document. If no files are passed, a default glob of `manifests/**/*.pp` will be used. --- lib/puppet/face/yardoc.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/puppet/face/yardoc.rb b/lib/puppet/face/yardoc.rb index 7b59c99..bb52f84 100644 --- a/lib/puppet/face/yardoc.rb +++ b/lib/puppet/face/yardoc.rb @@ -5,8 +5,7 @@ Puppet::Face.define(:yardoc, '0.0.1') do action(:yardoc) do default - when_invoked do |manifest, options| - + when_invoked do |*args| unless Puppet.features.yard? raise RuntimeError, "The 'yard' gem must be installed in order to use this face." end @@ -15,10 +14,22 @@ Puppet::Face.define(:yardoc, '0.0.1') do raise RuntimeError, "The 'rgen' gem must be installed in order to use this face." end + # 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) + require 'puppetx/yardoc/yard/plugin' # Hand off to YARD for further processing. - YARD::CLI::Yardoc.run(manifest) + YARD::CLI::Yardoc.run(*manifest_files) end end end