Permalink
Browse files

Hanna 0.1.2 can generate docs for gems

  • Loading branch information...
1 parent 5277d97 commit 71091b4d446b1c9910f32f10705da50f66951f76 @mislav mislav committed May 3, 2008
Showing with 54 additions and 11 deletions.
  1. +6 −3 README.markdown
  2. +46 −6 bin/hanna
  3. +2 −2 hanna.gemspec
View
@@ -4,11 +4,11 @@ Hanna is an RDoc template that scales. It's implemented in Haml, making the
sources clean and readable. It's built with simplicity, beauty and ease of
browsing in mind.
-Hanna is available from [GitHub][]:
+Hanna was made by [Mislav][] and is available from [GitHub][]:
gem install mislav-hanna
-After that you have two options. You can use the command-line tool:
+After that you have three options. You can use the command-line tool:
hanna -h
@@ -35,7 +35,10 @@ an example for [will_paginate][]:
Either way, it's the same as using RDoc.
-Hanna was crafted by [Mislav][].
+The last thing you can do with Hanna is generate documentation for installed
+gems. This is a replacement for the "gem rdoc" command.
+
+ [sudo] hanna --gems haml will_paginate
## A work in progress
View
@@ -2,15 +2,24 @@
if ARGV.size == 1 and ARGV.first == '-h'
puts <<-HELP
Hanna -- a better RDoc template
-Sample usage:
+Synopsis:
+ hanna [options] [file names...]
+ [sudo] hanna --gems [gem names...]
+
+Example usage:
hanna lib/**/*.rb
-Hanna passes all arguments to RDoc. To find more about RDoc options,
-see "rdoc -h". Default options:
+Hanna passes all arguments to RDoc. To find more about RDoc options, see
+"rdoc -h". Default options are:
-o doc --inline-source --charset=UTF-8
+The second form, with the "--gems" argument, serves the same purpose as
+the "gem rdoc" command: it generates documentation for installed gems.
+When no gem names are given, "hanna --gems" will install docs for EACH of
+the gems, which can, uh, take a little while.
+
HELP
exit 0
end
@@ -33,9 +42,40 @@ require 'hanna/rdoc_patch'
options = []
options << '-T' << 'hanna/hanna.rb'
-options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
options << '--inline-source' << '--charset=UTF-8'
-options.concat ARGV
+if ARGV.first == '--gems'
+ require 'rubygems/doc_manager'
+ Gem::DocManager.configured_args = options
+
+ gem_names = ARGV.dup
+ gem_names.shift
+
+ unless gem_names.empty?
+ specs = gem_names.inject([]) do |arr, name|
+ found = Gem::SourceIndex.from_installed_gems.search(name)
+ spec = found.sort_by {|s| s.version }.last
+ arr << spec if spec
+ arr
+ end
+ else
+ specs = Gem::SourceIndex.from_installed_gems.inject({}) do |all, pair|
+ full_name, spec = pair
+ if spec.has_rdoc? and (!all[spec.name] or spec.version > all[spec.name].version)
+ all[spec.name] = spec
+ end
+ all
+ end
+ specs = specs.values
+ puts "Hanna is installing documentation for #{specs.size} gem#{specs.size > 1 ? 's' : ''} ..."
+ end
+
+ specs.each do |spec|
+ Gem::DocManager.new(spec).generate_rdoc
+ end
+else
+ options << '-o' << 'doc' unless ARGV.include?('-o') or ARGV.include?('--op')
+ options.concat ARGV
-RDoc::RDoc.new.document(options)
+ RDoc::RDoc.new.document(options)
+end
View
@@ -1,7 +1,7 @@
Gem::Specification.new do |s|
s.name = 'hanna'
- s.version = '0.1.1'
- s.date = '2008-05-02'
+ s.version = '0.1.2'
+ s.date = '2008-05-03'
s.summary = "An RDoc template that rocks"
s.description = "Hanna is an RDoc template that scales. It's implemented in Haml, making its source clean and maintainable. It's built with simplicity, beauty and ease of browsing in mind."

0 comments on commit 71091b4

Please sign in to comment.