summaryrefslogtreecommitdiff
path: root/bin/rdoc
blob: fe619137fdd00b6c98a4f53664ce1d9aa87613ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env ruby
#
#  RDoc: Documentation tool for source code
#        (see lib/rdoc/rdoc.rb for more information)
#
#  Copyright (c) 2003 Dave Thomas
#  Released under the same terms as Ruby
#
#  $Revision$

## Transitional Hack ####
#
#  RDoc was initially distributed independently, and installed
#  itself into <prefix>/lib/ruby/site_ruby/<ver>/rdoc...
#
#  Now that RDoc is part of the distribution, it's installed into
#  <prefix>/lib/ruby/<ver>, which unfortunately appears later in the
#  search path. This means that if you have previously installed RDoc,
#  and then install from ruby-lang, you'll pick up the old one by
#  default. This hack checks for the condition, and readjusts the
#  search path if necessary.

def adjust_for_existing_rdoc(path)
  
  $stderr.puts %{
  It seems as if you have a previously-installed RDoc in
  the directory #{path}.

  Because this is now out-of-date, you might want to consider
  removing the directories:

    #{File.join(path, "rdoc")}

  and

    #{File.join(path, "markup")}

  }

  # Move all the site_ruby directories to the end
  p $:
  $:.replace($:.partition {|path| /site_ruby/ !~ path}.flatten)
  p $:
end

$:.each do |path|
  if /site_ruby/ =~ path 
    rdoc_path = File.join(path, 'rdoc', 'rdoc.rb')
    if File.exists?(rdoc_path)
      adjust_for_existing_rdoc(path)
      break
    end
  end
end

## End of Transitional Hack ##


require 'rdoc/rdoc'

begin
  r = RDoc::RDoc.new
  r.document(ARGV)
rescue RDoc::RDocError => e
  $stderr.puts e.message
  exit(1)
end