# RDoc::Parser - ri - phpman

= [**RDoc::Parser](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3AParser/markdown) < Object**

(from gem rdoc-7.2.0)
------------------------------------------------------------------------
A parser is simple a class that subclasses [RDoc::Parser](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3AParser/markdown) and implements
#scan to fill in an [RDoc::TopLevel](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3ATopLevel/markdown) with parsed data.

## The initialize method takes an [RDoc::TopLevel](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3ATopLevel/markdown) to fill with parsed
content, the name of the file to be parsed, the content of the file, an
[RDoc::Options](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3AOptions/markdown) object and an [RDoc::Stats](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3AStats/markdown) object to inform the user of
parsed items.  The scan method is then called to parse the file and must
return the [RDoc::TopLevel](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3ATopLevel/markdown) object.  By calling super these items will be
set for you.

## In order to be used by RDoc the parser needs to register the file
extensions it can parse.  Use ::parse_files_matching to register
extensions.

  require 'rdoc'

  class [RDoc::Parser::Xyz](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3AParser%3A%3AXyz/markdown) < [RDoc::Parser](https://www.chedong.com/phpMan.php/perldoc/RDoc%3A%3AParser/markdown)
    parse_files_matching /\.xyz$/

    def initialize top_level, file_name, content, options, stats
      super

      # extra initialization if needed
    end

    def scan
      # parse file and fill in @top_level
    end
  end
------------------------------------------------------------------------
= **Class methods:**

  alias_extension
  binary?
  can_parse
  can_parse_by_name
  check_modeline
  for
  new
  parse_files_matching
  parsers
  remove_modeline
  use_markup
  zip?

= **Instance methods:**

  file_name
  handle_tab_width

= **Attributes:**

  attr_reader file_name
  attr_reader parsers

