class Jazzy::DocIndex::LookupName

Helper for name lookup, really a cache for information as we try various strategies.

Attributes

name[R]

Public Class Methods

new(name) click to toggle source
# File lib/jazzy/doc_index.rb, line 141
def initialize(name)
  @name = name
end

Public Instance Methods

fully_qualified?() click to toggle source
# File lib/jazzy/doc_index.rb, line 145
def fully_qualified?
  name.start_with?('/')
end
objc?() click to toggle source
# File lib/jazzy/doc_index.rb, line 149
def objc?
  name.start_with?('-', '+')
end
parts() click to toggle source
# File lib/jazzy/doc_index.rb, line 153
def parts
  @parts ||= find_parts
end

Private Instance Methods

find_parts() click to toggle source

Turn a name as written into a list of components to be matched. Swift: Strip out odd characters and split ObjC: Compound names look like ‘+[Class(Category) method:]’

and need to become ['Class(Category)', '+method:']
# File lib/jazzy/doc_index.rb, line 164
def find_parts
  if name =~ /([+-])\[(\w+(?: ?\(\w+\))?) ([\w:]+)\]/
    [Regexp.last_match[2],
     Regexp.last_match[1] + Regexp.last_match[3]]
  else
    name
      .sub(%r{^[@\/]}, '') # ignore custom attribute reference, fully-qualified
      .gsub(/<.*?>/, '') # remove generic parameters
      .split(%r{(?<!\.)[/.](?!\.)}) # dot or slash, but not '...'
      .reject(&:empty?)
  end
end