Class: RDoc::RD

Inherits:
Object
  • Object
show all
Defined in:
lib/rdoc/rd.rb,
lib/rdoc/rd/block_parser.rb,
lib/rdoc/rd/inline_parser.rb

Overview

racc/parser.rb end

Defined Under Namespace

Classes: BlockParser, Inline, InlineParser

Class Method Summary collapse

Class Method Details

.parse(rd) ⇒ Object

Parses rd source and returns an RDoc::Markup::Document. If the =begin or =end lines are missing they will be added.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# 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