From a051319b34c33a8f3dd91236ffbabea179a2cdb4 Mon Sep 17 00:00:00 2001 From: Charlie Sharpsteen Date: Mon, 26 May 2014 17:55:43 -0700 Subject: [PATCH] Clobber YARD namespace proxies When creating an object, YARD will split the object name using `::` and recursively create proxy namespaces for each component. Unfortunately this process is optimized for Ruby and somewhat mangles Puppet code as Puppet class names are not capitalized. For now, dispense with this behavior by implementing `HostClassObject.new`. --- .../yard/code_objects/host_class_object.rb | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/puppetx/yardoc/yard/code_objects/host_class_object.rb b/lib/puppetx/yardoc/yard/code_objects/host_class_object.rb index 0927d91..28b6599 100644 --- a/lib/puppetx/yardoc/yard/code_objects/host_class_object.rb +++ b/lib/puppetx/yardoc/yard/code_objects/host_class_object.rb @@ -5,6 +5,29 @@ require_relative '../../../yardoc' module Puppetx::Yardoc::YARD::CodeObjects class HostClassObject < YARD::CodeObjects::NamespaceObject - # Nothing to see here yet... + # The `YARD::Codeobjects::Base` class pulls a bunch of shenanigans to + # insert proxy namespaces. Unfortunately, said shenanigans pick up on the + # `::` in Puppet names and start to mangle things based on rules for the + # Ruby language. + # + # Therefore, we must override `new` for great justice. + # + # TODO: Ask around on the YARD mailing list to see if there is a way around + # this ugliness. + # + # Alternately, consider ensuring all `proxy` objects resolve to a + # placeholder `NamespaceObject` as the name mangling behavior of these is + # easier to control. + def self.new(namespace, name, *args, &block) + # Standard Ruby boilerplate for `new` + obj = self.allocate + obj.send :initialize, namespace, name, *args + + # The last bit of `YARD::CodeObjects::Base.new`. + existing_obj = YARD::Registry.at(obj.path) + obj = existing_obj if existing_obj && existing_obj.class == self + yield(obj) if block_given? + obj + end end end