Class: Solargraph::YardMap
- Inherits:
-
Object
- Object
- Solargraph::YardMap
show all
- Includes:
- ApiMap::BundlerMethods
- Defined in:
- lib/solargraph/yard_map.rb,
lib/solargraph/yard_map/cache.rb,
lib/solargraph/yard_map/mapper.rb,
lib/solargraph/yard_map/helpers.rb,
lib/solargraph/yard_map/to_method.rb,
lib/solargraph/yard_map/mapper/to_method.rb,
lib/solargraph/yard_map/mapper/to_constant.rb,
lib/solargraph/yard_map/mapper/to_namespace.rb
Overview
The YardMap provides access to YARD documentation for the Ruby core, the stdlib, and gems.
Defined Under Namespace
Modules: Helpers
Classes: Cache, Mapper, NoYardocError, ToMethod
Instance Attribute Summary collapse
Instance Method Summary
collapse
require_from_bundle
Constructor Details
#initialize(required: [], directory: '', source_gems: [], with_dependencies: true) ⇒ YardMap
Returns a new instance of YardMap.
30
31
32
33
|
# File 'lib/solargraph/yard_map.rb', line 30
def initialize(required: [], directory: '', source_gems: [], with_dependencies: true)
@with_dependencies = with_dependencies
change required.to_set, directory, source_gems.to_set
end
|
Instance Attribute Details
#with_dependencies=(value) ⇒ Boolean
24
25
26
|
# File 'lib/solargraph/yard_map.rb', line 24
def with_dependencies=(value)
@with_dependencies = value
end
|
Instance Method Details
#base_required ⇒ Object
132
133
134
|
# File 'lib/solargraph/yard_map.rb', line 132
def base_required
@base_required ||= Set.new
end
|
#change(new_requires, new_directory, new_source_gems) ⇒ Boolean
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/solargraph/yard_map.rb', line 49
def change new_requires, new_directory, new_source_gems
return false if new_requires == base_required && new_directory == @directory && new_source_gems == @source_gems
@gem_paths = {}
base_required.replace new_requires
required.replace new_requires
required.add 'psych' if new_requires.include?('yaml')
@source_gems = new_source_gems
@directory = new_directory
process_requires
@rebindable_method_names = nil
@pin_class_hash = nil
@pin_select_cache = {}
pins.each { |p| p.source = :yard }
true
end
|
#directory ⇒ Object
136
137
138
|
# File 'lib/solargraph/yard_map.rb', line 136
def directory
@directory ||= ''
end
|
#load_yardoc(y) ⇒ YARD::Registry
97
98
99
100
101
102
103
104
105
106
107
|
# File 'lib/solargraph/yard_map.rb', line 97
def load_yardoc y
if y.is_a?(Array)
YARD::Registry.load y, true
else
YARD::Registry.load! y
end
rescue StandardError => e
Solargraph::Logging.logger.warn "Error loading yardoc '#{y}' #{e.class} #{e.message}"
yardocs.delete y
nil
end
|
#missing_docs ⇒ Array<String>
91
92
93
|
# File 'lib/solargraph/yard_map.rb', line 91
def missing_docs
@missing_docs ||= []
end
|
111
112
113
|
# File 'lib/solargraph/yard_map.rb', line 111
def path_pin path
pins.select { |p| p.path == path }.first
end
|
36
37
38
|
# File 'lib/solargraph/yard_map.rb', line 36
def pins
@pins ||= []
end
|
#rebindable_method_names ⇒ Set<String>
67
68
69
70
71
72
73
|
# File 'lib/solargraph/yard_map.rb', line 67
def rebindable_method_names
@rebindable_method_names ||= pins_by_class(Pin::Method)
.select { |pin| pin. && pin..include?('@yieldself') }
.map(&:name)
.concat(['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec', 'define_method'])
.to_set
end
|
#require_reference(path) ⇒ Location
Get the location of a file referenced by a require path.
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/solargraph/yard_map.rb', line 119
def require_reference path
spec = spec_for_require(path)
spec.full_require_paths.each do |rp|
file = File.join(rp, "#{path}.rb")
next unless File.file?(file)
return Solargraph::Location.new(file, Solargraph::Range.from_to(0, 0, 0, 0))
end
nil
rescue Gem::LoadError
nil
end
|
#required ⇒ Set<String>
81
82
83
|
# File 'lib/solargraph/yard_map.rb', line 81
def required
@required ||= Set.new
end
|
#unresolved_requires ⇒ Array<String>
86
87
88
|
# File 'lib/solargraph/yard_map.rb', line 86
def unresolved_requires
@unresolved_requires ||= []
end
|
#with_dependencies? ⇒ Boolean
40
41
42
43
|
# File 'lib/solargraph/yard_map.rb', line 40
def with_dependencies?
@with_dependencies ||= true unless @with_dependencies == false
@with_dependencies
end
|
#yardocs ⇒ Array<String>
76
77
78
|
# File 'lib/solargraph/yard_map.rb', line 76
def yardocs
@yardocs ||= []
end
|