From 918e3bc9ccb1950841c303a5e16e6565703f963c Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Thu, 19 Jun 2014 16:28:21 -0700 Subject: [PATCH] Tag all functions with @api public The Puppet Core uses a `.yardopts` file that hides all docstrings that do not have an API tag. This patch is a hack that allows `puppet yardoc` to extract documentation for parser functions shipped in the core. FIXME: This isn't the right way to solve the problem. The right way to solve the problem is to adjust the Puppet `.yardopts` file to a sane value. --- .../yardoc/yard/handlers/parser_function_handler.rb | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/puppetx/yardoc/yard/handlers/parser_function_handler.rb b/lib/puppetx/yardoc/yard/handlers/parser_function_handler.rb index aefe9d0..e53fda4 100644 --- a/lib/puppetx/yardoc/yard/handlers/parser_function_handler.rb +++ b/lib/puppetx/yardoc/yard/handlers/parser_function_handler.rb @@ -24,6 +24,12 @@ module Puppetx::Yardoc::YARD::Handlers return_type = options['type'] return_type ||= 'statement' # Default for newfunction obj.add_tag YARD::Tags::Tag.new(:return, '', return_type) + + # FIXME: This is a hack that allows us to document the Puppet Core which + # uses `--no-transitive-tag api` and then only shows things explicitly + # tagged with `public` or `private` api. This is kind of insane and + # should be fixed upstream. + obj.add_tag YARD::Tags::Tag.new(:api, 'public') end private @@ -37,7 +43,12 @@ module Puppetx::Yardoc::YARD::Handlers # name ::ParserFunctions, then there will be a clash. Hopefully the name # is sufficiently uncommon. obj = P(:root, 'ParserFunctions') - ::YARD::Registry.register PuppetNamespaceObject.new(:root, 'ParserFunctions') if obj.is_a?(Proxy) + if obj.is_a? Proxy + namespace_obj = PuppetNamespaceObject.new(:root, 'ParserFunctions') + namespace_obj.add_tag YARD::Tags::Tag.new(:api, 'public') + + ::YARD::Registry.register namespace_obj + end obj end