Class: Jazzy::DocIndex

Inherits:
Object
  • Object
show all
Defined in:
lib/jazzy/doc_index.rb

Overview

This class stores an index of symbol names for doing name lookup when resolving custom categories and autolinks.

Defined Under Namespace

Classes: LookupName, Scope

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(all_decls) ⇒ DocIndex

Returns a new instance of DocIndex.



76
77
78
# File 'lib/jazzy/doc_index.rb', line 76

def initialize(all_decls)
  @root_scope = Scope.new_root(all_decls.group_by(&:module_name))
end

Instance Attribute Details

#root_scopeObject (readonly)

Returns the value of attribute root_scope.



74
75
76
# File 'lib/jazzy/doc_index.rb', line 74

def root_scope
  @root_scope
end

Instance Method Details

#lookup(name, context = nil) ⇒ Object

Look up a name and return the matching SourceDeclaration or nil.

‘context` is an optional SourceDeclaration indicating where the text was found, affects name resolution - see `lookup_context()` below.



84
85
86
87
88
89
90
91
# File 'lib/jazzy/doc_index.rb', line 84

def lookup(name, context = nil)
  lookup_name = LookupName.new(name)

  return lookup_fully_qualified(lookup_name) if lookup_name.fully_qualified?
  return lookup_guess(lookup_name) if context.nil?

  lookup_context(lookup_name, context)
end