Add new PuppetNamespaceObject class
This class is functionally equivalent to the ModuleObject class that YARD uses for Ruby code. Using a new class allows us to gather YARD objects related to Puppet and separate them from the Ruby bits.
This commit is contained in:
parent
243d6889d5
commit
0307f0f5e9
|
@ -1,2 +1,3 @@
|
||||||
|
require_relative 'code_objects/puppet_namespace_object'
|
||||||
require_relative 'code_objects/defined_type_object'
|
require_relative 'code_objects/defined_type_object'
|
||||||
require_relative 'code_objects/host_class_object'
|
require_relative 'code_objects/host_class_object'
|
||||||
|
|
|
@ -1,31 +1,11 @@
|
||||||
require 'yard'
|
|
||||||
require 'puppet/pops'
|
require 'puppet/pops'
|
||||||
|
|
||||||
require_relative '../../../yardoc'
|
require_relative 'puppet_namespace_object'
|
||||||
|
|
||||||
module Puppetx::Yardoc::YARD::CodeObjects
|
module Puppetx::Yardoc::YARD::CodeObjects
|
||||||
class DefinedTypeObject < YARD::CodeObjects::NamespaceObject
|
class DefinedTypeObject < PuppetNamespaceObject
|
||||||
# A list of parameters attached to this class.
|
# A list of parameters attached to this class.
|
||||||
# @return [Array<Array(String, String)>]
|
# @return [Array<Array(String, String)>]
|
||||||
attr_accessor :parameters
|
attr_accessor :parameters
|
||||||
|
|
||||||
# NOTE: `YARD::Registry#resolve` requires a method with this signature to
|
|
||||||
# be present on all subclasses of `NamespaceObject`.
|
|
||||||
def inheritance_tree(include_mods = false)
|
|
||||||
[self]
|
|
||||||
end
|
|
||||||
|
|
||||||
# FIXME: We used to override `self.new` to ensure no YARD proxies were
|
|
||||||
# created for namespaces segments that did not map to a host class or
|
|
||||||
# defined type. Fighting the system in this way turned out to be
|
|
||||||
# counter-productive.
|
|
||||||
#
|
|
||||||
# However, if a proxy is left in, YARD will drop back to namspace-mangling
|
|
||||||
# heuristics that are very specific to Ruby and which produce ugly paths in
|
|
||||||
# the resulting output. Consider walking the namespace tree for each new
|
|
||||||
# class/type and ensuring that a placeholder other than a YARD proxy is
|
|
||||||
# used.
|
|
||||||
#
|
|
||||||
# def self.new(namespace, name, *args, &block)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
require 'yard'
|
||||||
|
|
||||||
|
require_relative '../../../yardoc'
|
||||||
|
|
||||||
|
module Puppetx::Yardoc::YARD::CodeObjects
|
||||||
|
class PuppetNamespaceObject < YARD::CodeObjects::NamespaceObject
|
||||||
|
# NOTE: `YARD::Registry#resolve` requires a method with this signature to
|
||||||
|
# be present on all subclasses of `NamespaceObject`.
|
||||||
|
def inheritance_tree(include_mods = false)
|
||||||
|
[self]
|
||||||
|
end
|
||||||
|
|
||||||
|
# FIXME: We used to override `self.new` to ensure no YARD proxies were
|
||||||
|
# created for namespaces segments that did not map to a host class or
|
||||||
|
# defined type. Fighting the system in this way turned out to be
|
||||||
|
# counter-productive.
|
||||||
|
#
|
||||||
|
# However, if a proxy is left in, YARD will drop back to namspace-mangling
|
||||||
|
# heuristics that are very specific to Ruby and which produce ugly paths in
|
||||||
|
# the resulting output. Need to find a way to address this.
|
||||||
|
#
|
||||||
|
# Tried:
|
||||||
|
#
|
||||||
|
# - Overriding self.new in the code object. Failed because self.new
|
||||||
|
# overrides are gross and difficult to pull off. Especially when
|
||||||
|
# replacing an existing override.
|
||||||
|
#
|
||||||
|
# - Adding functionality to the base handler to ensure something other
|
||||||
|
# than a proxy occupies each namespace segment. Failed because once a
|
||||||
|
# code object is created with a namespace, it will never update.
|
||||||
|
# Unless that namespace is set to a Proxy.
|
||||||
|
#
|
||||||
|
# def self.new(namespace, name, *args, &block)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
Loading…
Reference in New Issue