A parser is a class that subclasses RDoc::Parser and implements

#initialize top_level, file_name, body, options, stats

and

#scan

The initialize method takes a file name to be used, the body of the file, and an RDoc::Options object. The scan method is then called to return an appropriately parsed TopLevel code object.

RDoc::Parser::for is a factory that creates the correct parser for a given filename extension. Parsers have to register themselves RDoc::Parser using parse_files_matching as when they are loaded:

require "rdoc/parser"

class RDoc::Parser::Xyz < RDoc::Parser
  parse_files_matching /\.xyz$/ # <<<<

  def initialize top_level, file_name, body, options, stats
    ...
  end

  def scan
    ...
  end
end

If a plain text file is detected, RDoc also looks for a shebang line in case the file is a shell script.

Show files where this class is defined (1 file)
Register or log in to add new notes.