@@ -422,25 +422,28 @@ OTHER_RE = Regexp.new(
422422
423423# :startdoc:
424424
425+ ##
426+ # Creates a new parser for inline markup in the rd format. The +block_parser+
427+ # is used to for footnotes and labels in the inline text.
428+
425429def initialize block_parser
426430 @block_parser = block_parser
427431end
428432
433+ ##
434+ # Parses the +inline+ text from RD format into RDoc format.
435+
429436def parse inline
430437 @inline = inline
431438 @src = StringScanner.new inline
432439 @pre = ""
433440 @yydebug = true
434441 do_parse.to_s
435- rescue
436- puts $!
437- puts
438- puts @inline[0, @src.pos].inspect
439- puts @src.rest[0..40]
440- puts
441- raise
442442end
443443
444+ ##
445+ # Returns the next token from the inline text
446+
444447def next_token
445448 return [false, false] if @src.eos?
446449# p @src.rest if @yydebug
@@ -518,6 +521,9 @@ def next_token
518521 end
519522end
520523
524+ ##
525+ # Raises a ParseError when invalid formatting is found
526+
521527def on_error(et, ev, values)
522528 lines_of_rest = @src.rest.lines.to_a.length
523529 prev_words = prev_words_on_error(ev)
@@ -532,6 +538,9 @@ RD syntax error: line #{@block_parser.line_index - lines_of_rest}:
532538 raise ParseError, message
533539end
534540
541+ ##
542+ # Returns words before the error
543+
535544def prev_words_on_error(ev)
536545 pre = @pre
537546 if ev and /#{Regexp.quote(ev)}$/ =~ pre
@@ -540,6 +549,9 @@ def prev_words_on_error(ev)
540549 last_line(pre)
541550end
542551
552+ ##
553+ # Returns the last line of +src+
554+
543555def last_line(src)
544556 if n = src.rindex("\n")
545557 src[(n+1) .. -1]
@@ -549,6 +561,9 @@ def last_line(src)
549561end
550562private :last_line
551563
564+ ##
565+ # Returns words following an error
566+
552567def next_words_on_error
553568 if n = @src.rest.index("\n")
554569 @src.rest[0 .. (n-1)]
@@ -557,6 +572,9 @@ def next_words_on_error
557572 end
558573end
559574
575+ ##
576+ # Creates a new RDoc::RD::Inline for the +rdoc+ markup and the raw +reference+
577+
560578def inline rdoc, reference = rdoc
561579 RDoc::RD::Inline.new rdoc, reference
562580end
0 commit comments