558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
|
# File 'lib/coderunner/interactive_methods.rb', line 558
def self.process_args(argv)
options = default_options
opts = OptionParser.new do |opt|
opt.program_name = File.basename $0
opt.version = RDoc::VERSION
opt.release = nil
opt.summary_indent = ' ' * 4
directories = [
RDoc::RI::Paths::SYSDIR,
RDoc::RI::Paths::SITEDIR,
RDoc::RI::Paths::HOMEDIR
]
if RDoc::RI::Paths::GEMDIRS then
Gem.path.each do |dir|
directories << "#{dir}/doc/*/ri"
end
end
opt.banner = "Usage: \#{opt.program_name} [options] [names...]\n\nWhere name can be:\n\nClass | Class::method | Class#method | Class.method | method\n\nAll class names may be abbreviated to their minimum unambiguous form. If a name\nis ambiguous, all valid options will be listed.\n\nThe form '.' method matches either class or instance methods, while #method\nmatches only instance and ::method matches only class methods.\n\nFor example:\n\n \#{opt.program_name} Fil\n \#{opt.program_name} File\n \#{opt.program_name} File.new\n \#{opt.program_name} zip\n\nNote that shell quoting may be required for method names containing\npunctuation:\n\n \#{opt.program_name} 'Array.[]'\n \#{opt.program_name} compact\\\\!\n\nBy default ri searches for documentation in the following directories:\n\n \#{directories.join \"\\n \"}\n\nSpecifying the --system, --site, --home, --gems or --doc-dir options will\nlimit ri to searching only the specified directories.\n\nOptions may also be set in the 'RI' environment variable.\n EOT\n\n opt.separator nil\n opt.separator \"Options:\"\n opt.separator nil\n\n opt.on(\"--fmt=FORMAT\", \"--format=FORMAT\", \"-f\",\n RDoc::RI::Formatter::FORMATTERS.keys,\n \"Format to use when displaying output:\",\n \" \#{RDoc::RI::Formatter.list}\",\n \"Use 'bs' (backspace) with most pager\",\n \"programs. To use ANSI, either disable the\",\n \"pager or tell the pager to allow control\",\n \"characters.\") do |value|\n options[:formatter] = RDoc::RI::Formatter.for value\n end\n\n opt.separator nil\n\n opt.on(\"--doc-dir=DIRNAME\", \"-d\", Array,\n \"List of directories from which to source\",\n \"documentation in addition to the standard\",\n \"directories. May be repeated.\") do |value|\n value.each do |dir|\n unless File.directory? dir then\n raise OptionParser::InvalidArgument, \"\#{dir} is not a directory\"\n end\n\n options[:extra_doc_dirs] << File.expand_path(dir)\n end\n end\n\n opt.separator nil\n\n opt.on(\"--[no-]use-cache\",\n \"Whether or not to use ri's cache.\",\n \"True by default.\") do |value|\n options[:use_cache] = value\n end\n\n opt.separator nil\n\n opt.on(\"--no-standard-docs\",\n \"Do not include documentation from\",\n \"the Ruby standard library, site_lib,\",\n \"installed gems, or ~/.rdoc.\",\n \"Equivalent to specifying\",\n \"the options --no-system, --no-site, --no-gems,\",\n \"and --no-home\") do\n options[:use_system] = false\n options[:use_site] = false\n options[:use_gems] = false\n options[:use_home] = false\n end\n\n opt.separator nil\n\n opt.on(\"--[no-]system\",\n \"Include documentation from Ruby's standard\",\n \"library. Defaults to true.\") do |value|\n options[:use_system] = value\n end\n\n opt.separator nil\n\n opt.on(\"--[no-]site\",\n \"Include documentation from libraries\",\n \"installed in site_lib.\",\n \"Defaults to true.\") do |value|\n options[:use_site] = value\n end\n\n opt.separator nil\n\n opt.on(\"--[no-]gems\",\n \"Include documentation from RubyGems.\",\n \"Defaults to true.\") do |value|\n options[:use_gems] = value\n end\n\n opt.separator nil\n\n opt.on(\"--[no-]home\",\n \"Include documentation stored in ~/.rdoc.\",\n \"Defaults to true.\") do |value|\n options[:use_home] = value\n end\n\n opt.separator nil\n\n opt.on(\"--list-doc-dirs\",\n \"List the directories from which ri will\",\n \"source documentation on stdout and exit.\") do\n options[:list_doc_dirs] = true\n end\n\n opt.separator nil\n\n opt.on(\"--no-pager\", \"-T\",\n \"Send output directly to stdout,\",\n \"rather than to a pager.\") do\n options[:use_stdout] = true\n end\n\n opt.on(\"--interactive\", \"-i\",\n \"This makes ri go into interactive mode.\",\n \"When ri is in interactive mode it will\",\n \"allow the user to disambiguate lists of\",\n \"methods in case multiple methods match\",\n \"against a method search string. It also\",\n \"will allow the user to enter in a method\",\n \"name (with auto-completion, if readline\",\n \"is supported) when viewing a class.\") do\n options[:interactive] = true\n end\n\n opt.separator nil\n\n opt.on(\"--width=WIDTH\", \"-w\", OptionParser::DecimalInteger,\n \"Set the width of the output.\") do |value|\n options[:width] = value\n end\n end\n\n argv = ENV['RI'].to_s.split.concat argv\n\n opts.parse! argv\n\n options[:names] = argv\n\n options[:formatter] ||= RDoc::RI::Formatter.for('plain')\n options[:use_stdout] ||= !$stdout.tty?\n options[:use_stdout] ||= options[:interactive]\n options[:width] ||= 72\n\n options\n\nrescue OptionParser::InvalidArgument, OptionParser::InvalidOption => e\n puts opts\n puts\n puts e\n# exit 1\nend\n"
|