Method: YARD::Parser::SourceParser.register_parser_type

Defined in:
lib/yard/parser/source_parser.rb

.register_parser_type(type, parser_klass, extensions = nil) ⇒ void

This method returns an undefined value.

Registers a new parser type.

Examples:

Registering a parser for “java” files

SourceParser.register_parser_type :java, JavaParser, 'java'

Parameters:

  • a symbolic name for the parser type

  • a class that implements parsing and tokenization

  • (defaults to: nil)

    a list of extensions or a regex to match against the file extension

See Also:



139
140
141
142
143
144
145
# File 'lib/yard/parser/source_parser.rb', line 139

def register_parser_type(type, parser_klass, extensions = nil)
  unless Base > parser_klass
    raise ArgumentError, "expecting parser_klass to be a subclass of YARD::Parser::Base"
  end
  parser_type_extensions[type.to_sym] = extensions if extensions
  parser_types[type.to_sym] = parser_klass
end