/tools/Ruby/bin/rdoc

http://github.com/agross/netopenspace · Ruby · 67 lines · 29 code · 14 blank · 24 comment · 3 complexity · 60eea4b90696d1fb926e4d3c29d9f09d MD5 · raw file

  1. #!/usr/bin/env ruby
  2. #
  3. # RDoc: Documentation tool for source code
  4. # (see lib/rdoc/rdoc.rb for more information)
  5. #
  6. # Copyright (c) 2003 Dave Thomas
  7. # Released under the same terms as Ruby
  8. #
  9. # $Revision: 11708 $
  10. ## Transitional Hack ####
  11. #
  12. # RDoc was initially distributed independently, and installed
  13. # itself into <prefix>/lib/ruby/site_ruby/<ver>/rdoc...
  14. #
  15. # Now that RDoc is part of the distribution, it's installed into
  16. # <prefix>/lib/ruby/<ver>, which unfortunately appears later in the
  17. # search path. This means that if you have previously installed RDoc,
  18. # and then install from ruby-lang, you'll pick up the old one by
  19. # default. This hack checks for the condition, and readjusts the
  20. # search path if necessary.
  21. def adjust_for_existing_rdoc(path)
  22. $stderr.puts %{
  23. It seems as if you have a previously-installed RDoc in
  24. the directory #{path}.
  25. Because this is now out-of-date, you might want to consider
  26. removing the directories:
  27. #{File.join(path, "rdoc")}
  28. and
  29. #{File.join(path, "markup")}
  30. }
  31. # Move all the site_ruby directories to the end
  32. p $:
  33. $:.replace($:.partition {|path| /site_ruby/ !~ path}.flatten)
  34. p $:
  35. end
  36. $:.each do |path|
  37. if /site_ruby/ =~ path
  38. rdoc_path = File.join(path, 'rdoc', 'rdoc.rb')
  39. if File.exists?(rdoc_path)
  40. adjust_for_existing_rdoc(path)
  41. break
  42. end
  43. end
  44. end
  45. ## End of Transitional Hack ##
  46. require 'rdoc/rdoc'
  47. begin
  48. r = RDoc::RDoc.new
  49. r.document(ARGV)
  50. rescue RDoc::RDocError => e
  51. $stderr.puts e.message
  52. exit(1)
  53. end