In Files

  • rdoc/ri/formatter.rb

Files

Class/Module Index [+]

Quicksearch

RDoc::RI::AttributeFormatter

Handle text with attributes. We’re a base class: there are different presentation classes (one, for example, uses overstrikes to handle bold and underlining, while another using ANSI escape sequences.

Public Instance Methods

wrap(txt, prefix=@indent, linelen=@width) click to toggle source

Overrides base class. Looks for ... etc sequences and generates an array of AttrChars. This array is then used as the basis for the split.

 
               # File rdoc/ri/formatter.rb, line 289
def wrap(txt, prefix=@indent, linelen=@width)
  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
      write_attribute_text(prefix, line)
      prefix = next_prefix
      line = []
    end
    line.concat(word)
  end

  write_attribute_text(prefix, line) if line.length > 0
end
            

Protected Instance Methods

bold_print(txt) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 321
def bold_print(txt)
  @output.print txt
end
            
write_attribute_text(prefix, line) click to toggle source
 
               # File rdoc/ri/formatter.rb, line 313
def write_attribute_text(prefix, line)
  @output.print prefix
  line.each do |achar|
    @output.print achar.char
  end
  @output.puts
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.

blog comments powered by Disqus