(PDOC-35) Add a directive for puppet parameters

* Print yard documentation statistics for providers
* Define a directive which takes a type and a name
This commit is contained in:
Ian Kronquist 2015-08-10 10:16:26 -07:00
parent 676364bd17
commit 798cd5b816
5 changed files with 22 additions and 4 deletions

View File

@ -1,4 +1,5 @@
require 'puppet/face'
require 'puppet_x/puppetlabs/strings/yard/tags/directives'
Puppet::Face.define(:strings, '0.0.1') do
summary "Generate Puppet documentation with YARD."
@ -55,6 +56,9 @@ Puppet::Face.define(:strings, '0.0.1') do
# all over the terminal. This should definitely not be in real code, but
# it's very handy for debugging with pry
#class YARD::Logger; def progress(*args); end; end
YARD::Tags::Library.define_directive("puppet.provider.param",
:with_types_and_name,
PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetProviderParameterDirective)
yardoc_actions.generate_documentation(*yard_args)

View File

@ -21,6 +21,10 @@ module PuppetX::PuppetLabs
require 'puppet_x/puppetlabs/strings/yard/monkey_patches'
require 'puppet_x/puppetlabs/strings/yard/parser'
module Tags
require 'puppet_x/puppetlabs/strings/yard/tags/directives'
end
# This submodule contains code objects which are used to represent relevant
# aspects of puppet code in YARD's Registry
module CodeObjects

View File

@ -18,6 +18,10 @@ class YARD::CLI::Stats
def stats_for_definedtypes
output 'Puppet Types', *type_statistics(:definedtype)
end
def stats_for_providers
output 'Puppet Providers', *type_statistics(:provider)
end
end
class YARD::Logger

View File

@ -0,0 +1,9 @@
require 'puppet_x/puppetlabs/strings/yard/core_ext/yard'
# Creates a new code object based on the directive
class PuppetX::PuppetLabs::Strings::YARD::Tags::PuppetProviderParameterDirective < YARD::Tags::Directive
def call
return if object.nil?
object.parameters << ([tag.text] + tag.types)
object.parameter_details << {:name => tag.name, :desc => tag.text, :exists? => true, :provider => true}
end
end

View File

@ -11,11 +11,8 @@ def init
end
def parameter_details
params = object.parameter_details.map { |h| h[:name] }
@param_details = []
@param_details = object.parameter_details
@param_details = object.parameter_details.each { |h| h[:desc] = htmlify(h[:desc]) }
@template_helper.check_parameters_match_docs object
erb(:parameter_details)