Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 52 additions & 55 deletions lib/rdoc/markup/raw.rb
Original file line number Diff line number Diff line change
@@ -1,69 +1,66 @@
# frozen_string_literal: true
##
# 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 = []
@parts.concat parts
end

##
# Appends +text+
module RDoc
class Markup
# A section of text that is added to the output document as-is
class Raw
# The component parts of the list
#: Array[String]
attr_reader :parts

# Creates a new Raw containing +parts+
#: (*String) -> void
def initialize(*parts)
@parts = parts
end

def <<(text)
@parts << text
end
# Appends +text+
#: (String) -> void
def <<(text)
@parts << text
end

def ==(other) # :nodoc:
self.class == other.class and @parts == other.parts
end
#: (top) -> bool
def ==(other) # :nodoc:
self.class == other.class && @parts == other.parts
end

##
# Calls #accept_raw+ on +visitor+
# Calls #accept_raw+ on +visitor+
# @override
#: (untyped) -> void
def accept(visitor)
visitor.accept_raw(self)
end

def accept(visitor)
visitor.accept_raw self
end
# Appends +other+'s parts
#: (Raw) -> void
def merge(other)
@parts.concat(other.parts)
end

##
# Appends +other+'s parts
# @override
#: (PP) -> void
def pretty_print(q) # :nodoc:
self.class.name =~ /.*::(\w{1,4})/i

def merge(other)
@parts.concat other.parts
end
q.group(2, "[#{$1.downcase}: ", ']') do
q.seplist(@parts) do |part|
q.pp(part)
end
end
end

def pretty_print(q) # :nodoc:
self.class.name =~ /.*::(\w{1,4})/i
# Appends +texts+ onto this Paragraph
#: (*String) -> void
def push(*texts)
self.parts.concat(texts)
end

q.group 2, "[#{$1.downcase}: ", ']' do
q.seplist @parts do |part|
q.pp part
# The raw text
#: () -> String
def text
@parts.join(" ")
end
end
end

##
# Appends +texts+ onto this Paragraph

def push *texts
self.parts.concat texts
end

##
# The raw text

def text
@parts.join ' '
end

end