Skip to content

Loading…

Fixed #383 Option to install documentation for gems #1627

Closed
wants to merge 1 commit into from

3 participants

@dadooda

Hi guys

Please consider including this patch into the mainstream release. If there are any corrections I'll have to make, please let me know.

Thank you.

Alex

@dadooda

Any issues with this, guys?

@rtyler

Over a year and no activity on this, bummer :-/

@indirect
Bundler member

@rtyler if you rebase this and add some tests around the option, I'd be happy to merge it now.

@indirect indirect closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jan 15, 2012
  1. Fixed #383 Option to install documentation for gems.

    Alex Fortuna committed
Showing with 46 additions and 6 deletions.
  1. +8 −0 lib/bundler/cli.rb
  2. +31 −6 lib/bundler/source.rb
  3. +7 −0 man/bundle-install.ronn
View
8 lib/bundler/cli.rb
@@ -128,6 +128,7 @@ def check
If the bundle has already been installed, bundler will tell you so and then exit.
D
+
method_option "without", :type => :array, :banner =>
"Exclude gems that are part of the specified named group."
method_option "gemfile", :type => :string, :banner =>
@@ -158,6 +159,10 @@ def check
"Use the rubygems modern index instead of the API endpoint"
method_option "clean", :type => :boolean, :banner =>
"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
opts = options.dup
if opts[:without]
@@ -213,6 +218,9 @@ def install
Bundler.ui.be_quiet! if opts[:quiet]
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"]
# rubygems plugins sometimes hook into the gem install process
Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
View
37 lib/bundler/source.rb
@@ -1,15 +1,34 @@
-require "uri"
-require 'rubygems/user_interaction'
-require "rubygems/installer"
-require "rubygems/spec_fetcher"
-require "rubygems/format"
require "digest/sha1"
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 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
class Rubygems
+ include HandlesDoc
+
FORCE_MODERN_INDEX_LIMIT = 100 # threshold for switching back to the modern index instead of fetching every spec
attr_reader :remotes, :caches
@@ -94,6 +113,8 @@ def install(spec)
:wrappers => true,
:env_shebang => true
).install
+
+ optionally_install_doc(spec)
end
if spec.post_install_message
@@ -264,6 +285,8 @@ def remote_specs
end
class Path
+ include HandlesDoc
+
attr_reader :path, :options
# Kind of a hack, but needed for the lock file parser
attr_writer :name
@@ -562,6 +585,9 @@ def install(spec)
@installed = true
end
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
def load_spec_files
@@ -700,6 +726,5 @@ def in_cache(&blk)
Dir.chdir(cache_path, &blk)
end
end
-
end
end
View
7 man/bundle-install.ronn
@@ -10,6 +10,7 @@ bundle-install(1) -- Install the dependencies specified in your Gemfile
[--binstubs[=DIRECTORY]]
[--standalone[=GROUP1[ GROUP2...]]]
[--quiet]
+ [--ri] [--rdoc]
## DESCRIPTION
@@ -81,6 +82,9 @@ update process below under [CONSERVATIVE UPDATING][].
`bundle` directory and installs the bundle there. It also generates
a `bundle/bundler/setup.rb` file to replace Bundler's own setup.
+* `--ri`, `--rdoc`:
+ Install RI/RDoc documentation, respectively.
+
## DEPLOYMENT MODE
Bundler's defaults are optimized for development. To switch to
@@ -239,6 +243,9 @@ The settings that are remembered are:
Bundler runtime will also not try to make the gems in the
skipped groups available.
+* `--ri`, `--rdoc`:
+ See above.
+
## THE GEMFILE.LOCK
When you run `bundle install`, Bundler will persist the full names
Something went wrong with that request. Please try again.