The Nokogiri API was largely designed and implemented for Ruby 1.9, which pre-dates keyword argument support and parameter forwarding with .... As a result, many methods are using positional arguments where keyword arguments are probably better.
For example, Nokogiri::XML::Document.parse is declared as:
def parse(string_or_io, url = nil, encoding = nil, options = ParseOptions::DEFAULT_XML)
I would like to update these method signatures to support keyword arguments without dropping support (yet) for positional arguments. In the case of Document.parse, this might look like:
def parse(string_or_io,
url_ = nil, encoding_ = nil, options_ = XML::ParseOptions::DEFAULT_XML,
url: url_, encoding: encoding_, options: options_)
I would also like to update the docstrings to describe the keyword arguments, and remove documentation for the positional arguments.
Another example is Nokogiri::XML() which is defined as:
def XML(thing, url = nil, encoding = nil, options = XML::ParseOptions::DEFAULT_XML, &block)
Nokogiri::XML::Document.parse(thing, url, encoding, options, &block)
end
Methods that are forwarding positional arguments should be updated to more cleanly forward either keyword arguments or positional arguments, and avoid redeclaring parameter default values:
def XML(...)
Nokogiri::XML::Document.parse(...)
end
The Nokogiri API was largely designed and implemented for Ruby 1.9, which pre-dates keyword argument support and parameter forwarding with
.... As a result, many methods are using positional arguments where keyword arguments are probably better.For example,
Nokogiri::XML::Document.parseis declared as:I would like to update these method signatures to support keyword arguments without dropping support (yet) for positional arguments. In the case of
Document.parse, this might look like:I would also like to update the docstrings to describe the keyword arguments, and remove documentation for the positional arguments.
Another example is
Nokogiri::XML()which is defined as:Methods that are forwarding positional arguments should be updated to more cleanly forward either keyword arguments or positional arguments, and avoid redeclaring parameter default values: