Fix Nokogiri::XML::Node.new deprecation

Passing a Node as the second parameter to Node.new is deprecated. Please pass a Document instead, or prefer an alternative constructor like Node#add_child. This will become an error in a future release of Nokogiri.
pull/1803/head
Simon Legner 2 years ago
parent a6fe0238bf
commit 39f8849aef

@ -23,7 +23,7 @@ module Docs
end
def node(content)
node = Nokogiri::XML::Node.new 'h1', doc
node = Nokogiri::XML::Node.new 'h1', doc.document
node.content = content
node
end

@ -111,7 +111,7 @@ module Docs
# temporary solution due lack of mathjax/mathml support
css('.t-mfrac').each do |node|
fraction = Nokogiri::XML::Node.new('span', doc)
fraction = Nokogiri::XML::Node.new('span', doc.document)
node.css('td').each do |node|
fraction.add_child("<span>#{node.content}</span>")

@ -11,7 +11,7 @@ module Docs
css('.promo a').remove_attribute('style')
# Translate source files links to DevDocs links
links = Nokogiri::XML::Node.new('p', doc)
links = Nokogiri::XML::Node.new('p', doc.document)
links['class'] = '_links'
css('a.github').each do |node|

@ -8,7 +8,7 @@ module Docs
end
css('ul[id].simple li:first-child:last-child').each do |node|
heading = Nokogiri::XML::Node.new 'h3', doc
heading = Nokogiri::XML::Node.new 'h3', doc.document
heading['id'] = node.parent['id']
heading.children = node.children
node.parent.before(heading).remove

@ -2,7 +2,7 @@ module Docs
class Groovy
class CleanHtmlFilter < Filter
def new_node(content)
node = Nokogiri::XML::Node.new 'h1', doc
node = Nokogiri::XML::Node.new 'h1', doc.document
node.content = content
node
end

@ -107,7 +107,7 @@ module Docs
end
def generate_basic_html_table
table = Nokogiri::XML::Node.new('table', doc)
table = Nokogiri::XML::Node.new('table', doc.document)
table.add_child('<thead><tr id=bct-browser-type><tr id=bct-browsers><tbody>')

@ -7,7 +7,7 @@ module Docs
at_css('#mainCol').prepend_child at_css('#feature .wrapper').children
@doc = at_css('#mainCol')
container = Nokogiri::XML::Node.new 'div', doc
container = Nokogiri::XML::Node.new 'div', doc.document
container['class'] = '_simple'
container.children = doc.children
doc << container

@ -10,7 +10,7 @@ module Docs
container = at_css 'main'
# Add <dl> mentioning parent class and included modules
meta = Nokogiri::XML::Node.new 'dl', doc
meta = Nokogiri::XML::Node.new 'dl', doc.document
meta['class'] = 'meta'
if parent = at_css('#parent-class-section')

@ -229,14 +229,14 @@ module Docs
end
def convert_dl_to_table(dl)
table = Nokogiri::XML::Node.new('table', doc)
table = Nokogiri::XML::Node.new('table', doc.document)
table['class'] = 'attributes'
dl.css('> dt').each do |dt|
dd = dt.next_element
has_dd = dd.name == 'dd' rescue false
tr = Nokogiri::XML::Node.new('tr', doc)
tr = Nokogiri::XML::Node.new('tr', doc.document)
colspan = has_dd ? '' : ' colspan="2"' # handle <dt> without following <dt>
tr.add_child("<th#{colspan}>#{dt.inner_html.sub(/:$/, '')}</th>")

Loading…
Cancel
Save