Tweaked docs of the XML parsers.

This commit is contained in:
Yorick Peterse 2014-09-04 09:34:59 +02:00
parent 89689d9bb6
commit d8e2b97031
2 changed files with 24 additions and 11 deletions

View File

@ -1,14 +1,19 @@
module Oga
module HTML
##
# Low level AST parser for parsing HTML documents. See {Oga::XML::Parser}
# for more information.
# Parser for processing HTML input. This parser is a small wrapper around
# {Oga::XML::Parser} and takes care of setting the various options required
# for parsing HTML documents.
#
# A basic example:
#
# Oga::HTML::Parser.new('<meta charset="utf-8">').parse
#
class Parser < XML::Parser
##
# @param [String] data
# @param [String|IO] data
# @param [Hash] options
# @see Oga::XML::Parser#initialize
# @see [Oga::XML::Parser#initialize]
#
def initialize(data, options = {})
options = options.merge(:html => true)

View File

@ -1,11 +1,20 @@
##
# DOM parser for both XML and HTML.
#
# Note that this parser itself does not deal with special HTML void elements.
# It requires every tag to have a closing tag. As such you'll need to enable
# HTML parsing mode when parsing HTML. This can be done as following:
# This parser does not produce a dedicated AST, instead it emits XML nodes
# directly. Basic usage of this parser is as following:
#
# parser = Oga::XML::Parser.new(:html => true)
# parser = Oga::XML::Parser.new('<foo></foo>')
# document = parser.parse
#
# To enable HTML parsing you'd use the following instead:
#
# parser = Oga::XML::Parser.new('<foo></foo>', :html => true)
# document = parser.parse
#
# In both cases you can use either a String or an IO as the parser input. IO
# instances will result in lower memory overhead, especially when parsing large
# files.
#
class Oga::XML::Parser
@ -185,10 +194,9 @@ end
---- inner
##
# @param [String] data The input to parse.
#
# @param [String|IO] data The input to parse.
# @param [Hash] options
# @see Oga::XML::Lexer#initialize
# @see [Oga::XML::Lexer#initialize]
#
def initialize(data, options = {})
@data = data