2017-11-27 05:45:24 -05:00
|
|
|
# frozen_string_literal: true
|
2010-04-26 23:45:22 -04:00
|
|
|
##
|
|
|
|
# A section of text that is added to the output document as-is
|
|
|
|
|
|
|
|
class RDoc::Markup::Raw
|
|
|
|
|
|
|
|
##
|
|
|
|
# The component parts of the list
|
|
|
|
|
|
|
|
attr_reader :parts
|
|
|
|
|
|
|
|
##
|
|
|
|
# Creates a new Raw containing +parts+
|
|
|
|
|
|
|
|
def initialize *parts
|
|
|
|
@parts = []
|
2012-11-26 23:28:14 -05:00
|
|
|
@parts.concat parts
|
2010-04-26 23:45:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Appends +text+
|
|
|
|
|
|
|
|
def << text
|
|
|
|
@parts << text
|
|
|
|
end
|
|
|
|
|
|
|
|
def == other # :nodoc:
|
2012-11-26 23:28:14 -05:00
|
|
|
self.class == other.class and @parts == other.parts
|
2010-04-26 23:45:22 -04:00
|
|
|
end
|
|
|
|
|
2010-12-19 22:22:49 -05:00
|
|
|
##
|
|
|
|
# Calls #accept_raw+ on +visitor+
|
|
|
|
|
2010-04-26 23:45:22 -04:00
|
|
|
def accept visitor
|
|
|
|
visitor.accept_raw self
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Appends +other+'s parts
|
|
|
|
|
|
|
|
def merge other
|
2012-11-26 23:28:14 -05:00
|
|
|
@parts.concat other.parts
|
2010-04-26 23:45:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def pretty_print q # :nodoc:
|
2012-11-26 23:28:14 -05:00
|
|
|
self.class.name =~ /.*::(\w{1,4})/i
|
2010-04-26 23:45:22 -04:00
|
|
|
|
|
|
|
q.group 2, "[#{$1.downcase}: ", ']' do
|
|
|
|
q.seplist @parts do |part|
|
|
|
|
q.pp part
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Appends +texts+ onto this Paragraph
|
|
|
|
|
|
|
|
def push *texts
|
2012-11-26 23:28:14 -05:00
|
|
|
self.parts.concat texts
|
2010-04-26 23:45:22 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# The raw text
|
|
|
|
|
|
|
|
def text
|
|
|
|
@parts.join ' '
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2010-12-19 22:22:49 -05:00
|
|
|
|