lib/yard/code_objects/base.rb in yard-0.9.0 vs lib/yard/code_objects/base.rb in yard-0.9.1
- old
+ new
@@ -25,10 +25,11 @@
self
end
alias_method :<<, :push
end
+ extend NamespaceMapper
# Namespace separator
NSEP = '::'
# Regex-quoted namespace separator
@@ -103,16 +104,24 @@
# of the {NamespaceObject} and represent Ruby entities that can have
# objects defined within them. Classically these are modules and classes,
# though a DSL might create a custom {NamespaceObject} to describe a
# specific set of objects.
#
+ # == Separators
+ # Custom classes with different separator tokens should define their own
+ # separators using the {NamespaceMapper.register_separator} method. The
+ # standard Ruby separators have already been defined ('::', '#', '.', etc).
+ #
# @abstract This class should not be used directly. Instead, create a
- # subclass that implements {#path}, {#sep} or {#type}.
+ # subclass that implements {#path}, {#sep} or {#type}. You might also
+ # need to register custom separators if {#sep} uses alternate separator
+ # tokens.
# @see Registry
# @see #path
# @see #[]=
# @see NamespaceObject
+ # @see NamespaceMapper.register_separator
class Base
# The files the object was defined in. To add a file, use {#add_file}.
# @return [Array<String>] a list of files
# @see #add_file
attr_reader :files
@@ -223,11 +232,11 @@
@name = name.to_sym
@source_type = :ruby
@visibility = :public
@tags = []
@docstrings = {}
- @docstring = Docstring.new('', self)
+ @docstring = Docstring.new!('', [], self)
@namespace = nil
self.namespace = namespace
yield(self) if block_given?
end
@@ -478,9 +487,10 @@
# @option options [Serializers::Base] :serializer (nil) see Serializers
# @return [String] the rendered template
# @see Templates::Engine#render
def format(options = {})
options = options.merge(:object => self)
+ options = options.merge(:type => type) if !options[:type]
Templates::Engine.render(options)
end
# Inspects the object, returning the type and path
# @return [String] a string describing the object