Parses rd source and returns an RDoc::Markup::Document. If the
=begin or =end lines are missing they will be added.
# File lib/rdoc/rd.rb, line 78
def self.parse rd
rd = rd.lines.to_a
if rd.find { |i| /\S/ === i } and !rd.find{|i| /^=begin\b/ === i } then
rd.unshift("=begin\n").push("=end\n")
end
parser = RDoc::RD::BlockParser.new
document = parser.parse rd
# isn't this always true?
document.parts.shift if RDoc::Markup::BlankLine === document.parts.first
document.parts.pop if RDoc::Markup::BlankLine === document.parts.last
document
end