Skip to content

Instantly share code, notes, and snippets.

@betawaffle
Created October 25, 2011 16:59
Show Gist options
  • Save betawaffle/1313488 to your computer and use it in GitHub Desktop.
Save betawaffle/1313488 to your computer and use it in GitHub Desktop.
Rack-based Local YARD Server
require 'rubygems'
require 'yard'
libs = {}
gems = {}
base = ENV['GEM_PATH'].split(':')[1][%r{^.+(?=/.+@global$)}] rescue nil
if base
Gem.paths = {
'GEM_PATH' => Dir["#{base}/ruby-*"].join(':'),
'GEM_HOME' => ENV['GEM_HOME']
}
Gem.source_index.find_name('').each do |spec|
libs[spec.name] ||= []
libs[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)
end
end
run YARD::Server::RackAdapter.new(libs)
@trkoch
Copy link

trkoch commented May 21, 2014

For all gems available, use:

require 'rubygems'
require 'yard'

libs = {}
Gem.source_index.find_name('').each do |spec|
  libs[spec.name] ||= []
  libs[spec.name] << YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :ge
end

run YARD::Server::RackAdapter.new(libs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment