History

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.

Simon Legner committed 4 years ago

Commit 39f88491 parent a6fe0239 files · +10 −10Browse files

Unified · Split

9 files
  1. lib/docs/filters/core/title.rb +1 −1
  2. lib/docs/filters/cppref/clean_html.rb +1 −1
  3. lib/docs/filters/django_rest_framework/clean_html.rb +1 −1
  4. lib/docs/filters/godot/clean_html.rb +1 −1
  5. lib/docs/filters/groovy/clean_html.rb +1 −1
  6. lib/docs/filters/mdn/compat_tables.rb +1 −1
  7. lib/docs/filters/rails/clean_html_guides.rb +1 −1
  8. lib/docs/filters/rdoc/container.rb +1 −1
  9. lib/docs/filters/scala/clean_html_v3.rb +2 −2
lib/docs/filters/core/title.rb+1−1
@@ -23,7 +23,7 @@ module Docs · 22 unmodified lines
2323 end
2424
2525 def node(content)
26− node = Nokogiri::XML::Node.new 'h1', doc
26+ node = Nokogiri::XML::Node.new 'h1', doc.document
2727 node.content = content
2828 node
2929 end
lib/docs/filters/cppref/clean_html.rb+1−1
@@ -111,7 +111,7 @@ module Docs · 110 unmodified lines
111111
112112 # temporary solution due lack of mathjax/mathml support
113113 css('.t-mfrac').each do |node|
114− fraction = Nokogiri::XML::Node.new('span', doc)
114+ fraction = Nokogiri::XML::Node.new('span', doc.document)
115115
116116 node.css('td').each do |node|
117117 fraction.add_child("<span>#{node.content}</span>")
lib/docs/filters/django_rest_framework/clean_html.rb+1−1
@@ -11,7 +11,7 @@ module Docs · 10 unmodified lines
1111 css('.promo a').remove_attribute('style')
1212
1313 # Translate source files links to DevDocs links
14− links = Nokogiri::XML::Node.new('p', doc)
14+ links = Nokogiri::XML::Node.new('p', doc.document)
1515 links['class'] = '_links'
1616
1717 css('a.github').each do |node|
lib/docs/filters/godot/clean_html.rb+1−1
@@ -8,7 +8,7 @@ module Docs · 7 unmodified lines
88 end
99
1010 css('ul[id].simple li:first-child:last-child').each do |node|
11− heading = Nokogiri::XML::Node.new 'h3', doc
11+ heading = Nokogiri::XML::Node.new 'h3', doc.document
1212 heading['id'] = node.parent['id']
1313 heading.children = node.children
1414 node.parent.before(heading).remove
lib/docs/filters/groovy/clean_html.rb+1−1
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
22 class Groovy
33 class CleanHtmlFilter < Filter
44 def new_node(content)
5− node = Nokogiri::XML::Node.new 'h1', doc
5+ node = Nokogiri::XML::Node.new 'h1', doc.document
66 node.content = content
77 node
88 end
lib/docs/filters/mdn/compat_tables.rb+1−1
@@ -107,7 +107,7 @@ module Docs · 106 unmodified lines
107107 end
108108
109109 def generate_basic_html_table
110− table = Nokogiri::XML::Node.new('table', doc)
110+ table = Nokogiri::XML::Node.new('table', doc.document)
111111
112112 table.add_child('<thead><tr id=bct-browser-type><tr id=bct-browsers><tbody>')
113113
lib/docs/filters/rails/clean_html_guides.rb+1−1
@@ -7,7 +7,7 @@ module Docs · 6 unmodified lines
77 at_css('#mainCol').prepend_child at_css('#feature .wrapper').children
88 @doc = at_css('#mainCol')
99
10− container = Nokogiri::XML::Node.new 'div', doc
10+ container = Nokogiri::XML::Node.new 'div', doc.document
1111 container['class'] = '_simple'
1212 container.children = doc.children
1313 doc << container
lib/docs/filters/rdoc/container.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
1010 container = at_css 'main'
1111
1212 # Add <dl> mentioning parent class and included modules
13− meta = Nokogiri::XML::Node.new 'dl', doc
13+ meta = Nokogiri::XML::Node.new 'dl', doc.document
1414 meta['class'] = 'meta'
1515
1616 if parent = at_css('#parent-class-section')
lib/docs/filters/scala/clean_html_v3.rb+2−2
@@ -229,14 +229,14 @@ module Docs · 228 unmodified lines
229229 end
230230
231231 def convert_dl_to_table(dl)
232− table = Nokogiri::XML::Node.new('table', doc)
232+ table = Nokogiri::XML::Node.new('table', doc.document)
233233 table['class'] = 'attributes'
234234
235235 dl.css('> dt').each do |dt|
236236 dd = dt.next_element
237237 has_dd = dd.name == 'dd' rescue false
238238
239− tr = Nokogiri::XML::Node.new('tr', doc)
239+ tr = Nokogiri::XML::Node.new('tr', doc.document)
240240 colspan = has_dd ? '' : ' colspan="2"' # handle <dt> without following <dt>
241241 tr.add_child("<th#{colspan}>#{dt.inner_html.sub(/:$/, '')}</th>")
242242