Sha256: e337c44173b453d7ba3151bc029fdd8dee2d0bd1635261daa1c8d10e760b0918

Contents?: true

Size: 935 Bytes

Versions: 94

Compression:

Stored size: 935 Bytes

Contents

##
# A section of verbatim text

class RDoc::Markup::Verbatim < RDoc::Markup::Raw

  ##
  # Format of this verbatim section

  attr_accessor :format

  def initialize *parts # :nodoc:
    super

    @format = nil
  end

  ##
  # Calls #accept_verbatim on +visitor+

  def accept visitor
    visitor.accept_verbatim self
  end

  ##
  # Collapses 3+ newlines into two newlines

  def normalize
    parts = []

    newlines = 0

    @parts.each do |part|
      case part
      when /^\s*\n/ then
        newlines += 1
        parts << part if newlines == 1
      else
        newlines = 0
        parts << part
      end
    end

    parts.pop if parts.last =~ /\A\r?\n\z/

    @parts = parts
  end

  ##
  # Is this verbatim section ruby code?

  def ruby?
    @format ||= nil # TODO for older ri data, switch the tree to marshal_dump
    @format == :ruby
  end

  ##
  # The text of the section

  def text
    @parts.join
  end

end

Version data entries

94 entries across 74 versions & 20 rubygems

Version Path
active_mailer-0.0.10 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/verbatim.rb
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
active_mailer-0.0.9 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/verbatim.rb
active_mailer-0.0.8 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/verbatim.rb
active_mailer-0.0.7 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/verbatim.rb
active_mailer-0.0.6 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/verbatim.rb
font-awesome-rails-3.1.1.2 vendor/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
font-awesome-rails-3.1.1.2 vendor/ruby/2.0.0/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
font-awesome-rails-3.1.1.1 vendor/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
font-awesome-rails-3.1.1.1 vendor/ruby/2.0.0/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
challah-1.0.0.beta3 vendor/bundle/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
fc-webicons-0.0.4 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
challah-1.0.0.beta2 vendor/bundle/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
challah-1.0.0.beta vendor/bundle/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
challah-1.0.0.beta vendor/bundle/gems/rdoc-3.12/lib/rdoc/markup/verbatim.rb
fc-webicons-0.0.3 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
fc-webicons-0.0.2 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
fc-webicons-0.0.1 vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.2/lib/rdoc/markup/verbatim.rb
rdoc-3.12.2 lib/rdoc/markup/verbatim.rb
active_mailer-0.0.5 test/fixtures/dummyapp_rails_3.2/vendor/bundle/ruby/1.9.1/gems/rdoc-3.12.1/lib/rdoc/markup/verbatim.rb