Skip to content

Commit

Permalink
Merge 4489ef4 into 9f14dbf
Browse files Browse the repository at this point in the history
  • Loading branch information
tonobo committed Apr 20, 2017
2 parents 9f14dbf + 4489ef4 commit 658123e
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions lib/yard/cli/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,26 @@ def add_gems
end
end

def add_gems_from_gemfile(gemfile = nil)
def add_gems_from_gemfile(gemfile = nil, dependencies_only = false)
require 'bundler'
gemfile ||= "Gemfile"
if File.exist?("#{gemfile}.lock")
Bundler::LockfileParser.new(File.read("#{gemfile}.lock")).specs.each do |spec|
libraries[spec.name] ||= []
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)]
if dependencies_only
parsed_gemfile = Bundler::LockfileParser.new(File.read("#{gemfile}.lock"))
parsed_gemfile.dependencies.each do |dep|
libraries[dep.name] ||= []
specs = parsed_gemfile.specs.select do |spec|
spec.name == dep.name
end
specs.each do |spec|
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)]
end
end
else
Bundler::LockfileParser.new(File.read("#{gemfile}.lock")).specs.each do |spec|
libraries[spec.name] ||= []
libraries[spec.name] |= [YARD::Server::LibraryVersion.new(spec.name, spec.version.to_s, nil, :gem)]
end
end
else
log.warn "Cannot find #{gemfile}.lock, ignoring --gemfile option"
Expand Down Expand Up @@ -174,6 +187,9 @@ def optparse(*args)
opts.on('-G', '--gemfile [GEMFILE]', 'Serves documentation for gems from Gemfile') do |gemfile|
add_gems_from_gemfile(gemfile)
end
opts.on('--gemfile-deps [GEMFILE]', 'Serves documentation for gems from Gemfile (Just dependencies)') do |gemfile|
add_gems_from_gemfile(gemfile, true)
end
opts.on('-t', '--template-path PATH',
'The template path to look for templates in. (used with -t).') do |path|
template_paths << path
Expand Down

0 comments on commit 658123e

Please sign in to comment.