Skip to content

Commit

Permalink
Fixed rubygems#383 Option to install documentation for gems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Fortuna committed Jan 15, 2012
1 parent 7f7f7c0 commit 10181fd
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
8 changes: 8 additions & 0 deletions lib/bundler/cli.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ def check
If the bundle has already been installed, bundler will tell you so and then exit. If the bundle has already been installed, bundler will tell you so and then exit.
D D

method_option "without", :type => :array, :banner => method_option "without", :type => :array, :banner =>
"Exclude gems that are part of the specified named group." "Exclude gems that are part of the specified named group."
method_option "gemfile", :type => :string, :banner => method_option "gemfile", :type => :string, :banner =>
Expand Down Expand Up @@ -158,6 +159,10 @@ def check
"Use the rubygems modern index instead of the API endpoint" "Use the rubygems modern index instead of the API endpoint"
method_option "clean", :type => :boolean, :banner => method_option "clean", :type => :boolean, :banner =>
"Run bundle clean automatically after install" "Run bundle clean automatically after install"
method_option "ri", :type => :boolean, :banner =>
"Install RI documentation"
method_option "rdoc", :type => :boolean, :banner =>
"Install RDoc documentation"
def install def install
opts = options.dup opts = options.dup
if opts[:without] if opts[:without]
Expand Down Expand Up @@ -213,6 +218,9 @@ def install
Bundler.ui.be_quiet! if opts[:quiet] Bundler.ui.be_quiet! if opts[:quiet]
Bundler.settings[:clean] = opts[:clean] if opts[:clean] Bundler.settings[:clean] = opts[:clean] if opts[:clean]


Bundler.settings[:ri] = true if opts[:ri]
Bundler.settings[:rdoc] = true if opts[:rdoc]

Bundler::Fetcher.disable_endpoint = opts["full-index"] Bundler::Fetcher.disable_endpoint = opts["full-index"]
# rubygems plugins sometimes hook into the gem install process # rubygems plugins sometimes hook into the gem install process
Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins) Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
Expand Down
37 changes: 31 additions & 6 deletions lib/bundler/source.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,15 +1,34 @@
require "uri"
require 'rubygems/user_interaction'
require "rubygems/installer"
require "rubygems/spec_fetcher"
require "rubygems/format"
require "digest/sha1" require "digest/sha1"
require "open3" require "open3"
require "rubygems/doc_manager"
require "rubygems/format"
require "rubygems/installer"
require "rubygems/spec_fetcher"
require "rubygems/user_interaction"
require "uri"


module Bundler module Bundler
module Source module Source
module HandlesDoc
def optionally_install_doc(spec)
if Bundler.settings[:ri]
docm ||= Gem::DocManager.new(spec)
Bundler.ui.info " +ri"
docm.generate_ri
end

if Bundler.settings[:rdoc]
docm ||= Gem::DocManager.new(spec)
Bundler.ui.info " +rdoc"
docm.generate_rdoc
end
end
end # HandlesDoc

# TODO: Refactor this class # TODO: Refactor this class
class Rubygems class Rubygems
include HandlesDoc

FORCE_MODERN_INDEX_LIMIT = 100 # threshold for switching back to the modern index instead of fetching every spec FORCE_MODERN_INDEX_LIMIT = 100 # threshold for switching back to the modern index instead of fetching every spec


attr_reader :remotes, :caches attr_reader :remotes, :caches
Expand Down Expand Up @@ -94,6 +113,8 @@ def install(spec)
:wrappers => true, :wrappers => true,
:env_shebang => true :env_shebang => true
).install ).install

optionally_install_doc(spec)
end end


if spec.post_install_message if spec.post_install_message
Expand Down Expand Up @@ -264,6 +285,8 @@ def remote_specs
end end


class Path class Path
include HandlesDoc

attr_reader :path, :options attr_reader :path, :options
# Kind of a hack, but needed for the lock file parser # Kind of a hack, but needed for the lock file parser
attr_writer :name attr_writer :name
Expand Down Expand Up @@ -562,6 +585,9 @@ def install(spec)
@installed = true @installed = true
end end
generate_bin(spec) generate_bin(spec)

# NOTE: RI/RDoc for Git gems requires a lot more hacking. Paths need to be sorted out, as well as RDoc internals to search in `bundler/doc/` or something.
#optionally_install_doc(spec)
end end


def load_spec_files def load_spec_files
Expand Down Expand Up @@ -700,6 +726,5 @@ def in_cache(&blk)
Dir.chdir(cache_path, &blk) Dir.chdir(cache_path, &blk)
end end
end end

end end
end end
7 changes: 7 additions & 0 deletions man/bundle-install.ronn
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
[--binstubs[=DIRECTORY]] [--binstubs[=DIRECTORY]]
[--standalone[=GROUP1[ GROUP2...]]] [--standalone[=GROUP1[ GROUP2...]]]
[--quiet] [--quiet]
[--ri] [--rdoc]


## DESCRIPTION ## DESCRIPTION


Expand Down Expand Up @@ -81,6 +82,9 @@ update process below under [CONSERVATIVE UPDATING][].
`bundle` directory and installs the bundle there. It also generates `bundle` directory and installs the bundle there. It also generates
a `bundle/bundler/setup.rb` file to replace Bundler's own setup. a `bundle/bundler/setup.rb` file to replace Bundler's own setup.


* `--ri`, `--rdoc`:
Install RI/RDoc documentation, respectively.

## DEPLOYMENT MODE ## DEPLOYMENT MODE


Bundler's defaults are optimized for development. To switch to Bundler's defaults are optimized for development. To switch to
Expand Down Expand Up @@ -239,6 +243,9 @@ The settings that are remembered are:
Bundler runtime will also not try to make the gems in the Bundler runtime will also not try to make the gems in the
skipped groups available. skipped groups available.


* `--ri`, `--rdoc`:
See above.

## THE GEMFILE.LOCK ## THE GEMFILE.LOCK


When you run `bundle install`, Bundler will persist the full names When you run `bundle install`, Bundler will persist the full names
Expand Down

0 comments on commit 10181fd

Please sign in to comment.