diff options
author | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-02 06:01:12 +0000 |
---|---|---|
committer | dave <dave@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-01-02 06:01:12 +0000 |
commit | 62cbbfb24be234c3d520630cba2b0ee119db43a6 (patch) | |
tree | c389921b2db0f0622c37ac351b61ce7b48bdaeef /lib/rdoc/ri | |
parent | 76aec3b5295183786fb2274e4e7105806f406f67 (diff) |
Finish documenting internal stuff. See Changelog for other details
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@5364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rdoc/ri')
-rw-r--r-- | lib/rdoc/ri/ri_descriptions.rb | 14 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_formatter.rb | 25 | ||||
-rw-r--r-- | lib/rdoc/ri/ri_options.rb | 35 |
3 files changed, 42 insertions, 32 deletions
diff --git a/lib/rdoc/ri/ri_descriptions.rb b/lib/rdoc/ri/ri_descriptions.rb index 9bd5c2d13b..96041f1c7e 100644 --- a/lib/rdoc/ri/ri_descriptions.rb +++ b/lib/rdoc/ri/ri_descriptions.rb @@ -100,6 +100,12 @@ module RI "Module" end + # the 'ClassDescription' subclass overrides this + # to format up the name of a parent + def superclass_string + nil + end + private def merge(into, from) @@ -116,6 +122,14 @@ module RI def display_name "Class" end + + def superclass_string + if @superclass && @superclass != "Object" + @superclass + else + nil + end + end end diff --git a/lib/rdoc/ri/ri_formatter.rb b/lib/rdoc/ri/ri_formatter.rb index f41a815435..8fd214437d 100644 --- a/lib/rdoc/ri/ri_formatter.rb +++ b/lib/rdoc/ri/ri_formatter.rb @@ -197,7 +197,6 @@ module RI end end - ###################################################################### def display_flow(flow) flow.each do |f| @@ -207,6 +206,7 @@ module RI end + ###################################################################### # Handle text with attributes. We're a base class: there are # different presentation classes (one, for example, uses overstrikes # to handle bold and underlinig, while another using ANSI escape @@ -278,27 +278,30 @@ module RI return unless txt && !txt.empty? txt = add_attributes_to(txt) + next_prefix = prefix.tr("^ ", " ") + linelen -= prefix.size line = [] until txt.empty? word = txt.next_word - if word.size + line.size > linelen - @indent.size - write_attribute_text(line) + if word.size + line.size > linelen + write_attribute_text(prefix, line) + prefix = next_prefix line = [] end line.concat(word) end - write_attribute_text(line) if line.length > 0 + write_attribute_text(prefix, line) if line.length > 0 end protected # overridden in specific formatters - def write_attribute_text(line) - print @indent + def write_attribute_text(prefix, line) + print prefix line.each do |achar| print achar.char end @@ -340,8 +343,8 @@ module RI BS = "\C-h" - def write_attribute_text(line) - print @indent + def write_attribute_text(prefix, line) + print prefix line.each do |achar| attr = achar.attr if (attr & (ITALIC+CODE)) != 0 @@ -371,15 +374,13 @@ module RI class AnsiFormatter < AttributeFormatter - BS = "\C-h" - def initialize(*args) print "\033[0m" super end - def write_attribute_text(line) - print @indent + def write_attribute_text(prefix, line) + print prefix curr_attr = 0 line.each do |achar| attr = achar.attr diff --git a/lib/rdoc/ri/ri_options.rb b/lib/rdoc/ri/ri_options.rb index 9b0704d421..fe323ed45f 100644 --- a/lib/rdoc/ri/ri_options.rb +++ b/lib/rdoc/ri/ri_options.rb @@ -16,6 +16,9 @@ module RI # can't find a pager attr_accessor :use_stdout + # should we just display a class list and exit + attr_reader :list_classes + # The width of the output line attr_reader :width @@ -28,6 +31,10 @@ module RI [ "--help", "-h", nil, "you're looking at it" ], + [ "--classes", "-c", nil, + "Display the names of classes and modules we\n" + + "know about"], + [ "--format", "-f", "<name>", "Format to use when displaying output:\n" + " " + RI::TextFormatter.list + "\n" + @@ -112,8 +119,8 @@ module RI EOT if short_form - class_list - puts "For help, type 'ri -h'" + puts "For help on options, type 'ri -h'" + puts "For a list of classes I know about, type 'ri -c'" else puts "Options:\n\n" OPTION_LIST.each do |long, short, arg, desc| @@ -136,30 +143,16 @@ module RI end end - def OptionList.class_list - paths = RI::Paths::PATH - if paths.empty? - puts "Before using ri, you need to generate documentation" - puts "using 'rdoc' with the --ri option" - else - @ri_reader = RI::RiReader.new(RI::RiCache.new(paths)) - puts - puts "Classes and modules I know about:" - puts - puts @ri_reader.class_names.sort.join(", ") - puts - end - end - end # Parse command line options. def parse - @use_stdout = !STDOUT.tty? - @width = 72 - @formatter = RI::TextFormatter.for("plain") + @use_stdout = !STDOUT.tty? + @width = 72 + @formatter = RI::TextFormatter.for("plain") + @list_classes = false begin @@ -170,6 +163,8 @@ module RI case opt when "--help" then OptionList.usage when "--no-pager" then @use_stdout = true + when "--classes" then @list_classes = true + when "--format" @formatter = RI::TextFormatter.for(arg) unless @formatter |