Module: Solargraph::Yardoc
- Defined in:
- lib/solargraph/yardoc.rb
Overview
Methods for caching and loading YARD documentation for gems.
Class Method Summary collapse
-
.cache(gemspec) ⇒ String
Build and cache a gem’s yardoc and return the path.
-
.cached?(gemspec) ⇒ Boolean
True if the gem yardoc is cached.
-
.load!(gemspec) ⇒ Array<YARD::CodeObjects::Base>
Load a gem’s yardoc and return its code objects.
-
.path_for(gemspec) ⇒ String
Get the absolute path for a cached gem yardoc.
Class Method Details
.cache(gemspec) ⇒ String
Build and cache a gem’s yardoc and return the path. If the cache already exists, do nothing and return the path.
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/solargraph/yardoc.rb', line 14 def cache(gemspec) path = path_for(gemspec) return path if cached?(gemspec) Solargraph.logger.info "Caching yardoc for #{gemspec.name} #{gemspec.version}" Dir.chdir gemspec.gem_dir do `yardoc --db #{path} --no-output --plugin solargraph` end path end |
.cached?(gemspec) ⇒ Boolean
True if the gem yardoc is cached.
28 29 30 31 |
# File 'lib/solargraph/yardoc.rb', line 28 def cached?(gemspec) yardoc = File.join(path_for(gemspec), 'complete') File.exist?(yardoc) end |
.load!(gemspec) ⇒ Array<YARD::CodeObjects::Base>
Note:
This method modifies the global YARD registry.
Load a gem’s yardoc and return its code objects.
47 48 49 50 |
# File 'lib/solargraph/yardoc.rb', line 47 def load!(gemspec) YARD::Registry.load! path_for(gemspec) YARD::Registry.all end |
.path_for(gemspec) ⇒ String
Get the absolute path for a cached gem yardoc.
37 38 39 |
# File 'lib/solargraph/yardoc.rb', line 37 def path_for(gemspec) File.join(Solargraph::Cache.base_dir, "yard-#{YARD::VERSION}", "#{gemspec.name}-#{gemspec.version}.yardoc") end |