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
23 end23 end
24 24
25 def node(content)25 def node(content)
26 node = Nokogiri::XML::Node.new 'h1', doc26 node = Nokogiri::XML::Node.new 'h1', doc.document
27 node.content = content27 node.content = content
28 node28 node
29 end29 end
lib/docs/filters/cppref/clean_html.rb+1−1
@@ -111,7 +111,7 @@ module Docs · 110 unmodified lines
111 111
112 # temporary solution due lack of mathjax/mathml support112 # temporary solution due lack of mathjax/mathml support
113 css('.t-mfrac').each do |node|113 css('.t-mfrac').each do |node|
114 fraction = Nokogiri::XML::Node.new('span', doc)114 fraction = Nokogiri::XML::Node.new('span', doc.document)
115 115
116 node.css('td').each do |node|116 node.css('td').each do |node|
117 fraction.add_child("<span>#{node.content}</span>")117 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
11 css('.promo a').remove_attribute('style')11 css('.promo a').remove_attribute('style')
12 12
13 # Translate source files links to DevDocs links13 # Translate source files links to DevDocs links
14 links = Nokogiri::XML::Node.new('p', doc)14 links = Nokogiri::XML::Node.new('p', doc.document)
15 links['class'] = '_links'15 links['class'] = '_links'
16 16
17 css('a.github').each do |node|17 css('a.github').each do |node|
lib/docs/filters/godot/clean_html.rb+1−1
@@ -8,7 +8,7 @@ module Docs · 7 unmodified lines
8 end8 end
9 9
10 css('ul[id].simple li:first-child:last-child').each do |node|10 css('ul[id].simple li:first-child:last-child').each do |node|
11 heading = Nokogiri::XML::Node.new 'h3', doc11 heading = Nokogiri::XML::Node.new 'h3', doc.document
12 heading['id'] = node.parent['id']12 heading['id'] = node.parent['id']
13 heading.children = node.children13 heading.children = node.children
14 node.parent.before(heading).remove14 node.parent.before(heading).remove
lib/docs/filters/groovy/clean_html.rb+1−1
@@ -2,7 +2,7 @@ module Docs · 1 unmodified line
2 class Groovy2 class Groovy
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def new_node(content)4 def new_node(content)
5 node = Nokogiri::XML::Node.new 'h1', doc5 node = Nokogiri::XML::Node.new 'h1', doc.document
6 node.content = content6 node.content = content
7 node7 node
8 end8 end
lib/docs/filters/mdn/compat_tables.rb+1−1
@@ -107,7 +107,7 @@ module Docs · 106 unmodified lines
107 end107 end
108 108
109 def generate_basic_html_table109 def generate_basic_html_table
110 table = Nokogiri::XML::Node.new('table', doc)110 table = Nokogiri::XML::Node.new('table', doc.document)
111 111
112 table.add_child('<thead><tr id=bct-browser-type><tr id=bct-browsers><tbody>')112 table.add_child('<thead><tr id=bct-browser-type><tr id=bct-browsers><tbody>')
113 113
lib/docs/filters/rails/clean_html_guides.rb+1−1
@@ -7,7 +7,7 @@ module Docs · 6 unmodified lines
7 at_css('#mainCol').prepend_child at_css('#feature .wrapper').children7 at_css('#mainCol').prepend_child at_css('#feature .wrapper').children
8 @doc = at_css('#mainCol')8 @doc = at_css('#mainCol')
9 9
10 container = Nokogiri::XML::Node.new 'div', doc10 container = Nokogiri::XML::Node.new 'div', doc.document
11 container['class'] = '_simple'11 container['class'] = '_simple'
12 container.children = doc.children12 container.children = doc.children
13 doc << container13 doc << container
lib/docs/filters/rdoc/container.rb+1−1
@@ -10,7 +10,7 @@ module Docs · 9 unmodified lines
10 container = at_css 'main'10 container = at_css 'main'
11 11
12 # Add <dl> mentioning parent class and included modules12 # Add <dl> mentioning parent class and included modules
13 meta = Nokogiri::XML::Node.new 'dl', doc13 meta = Nokogiri::XML::Node.new 'dl', doc.document
14 meta['class'] = 'meta'14 meta['class'] = 'meta'
15 15
16 if parent = at_css('#parent-class-section')16 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
229 end229 end
230 230
231 def convert_dl_to_table(dl)231 def convert_dl_to_table(dl)
232 table = Nokogiri::XML::Node.new('table', doc)232 table = Nokogiri::XML::Node.new('table', doc.document)
233 table['class'] = 'attributes'233 table['class'] = 'attributes'
234 234
235 dl.css('> dt').each do |dt|235 dl.css('> dt').each do |dt|
236 dd = dt.next_element236 dd = dt.next_element
237 has_dd = dd.name == 'dd' rescue false237 has_dd = dd.name == 'dd' rescue false
238 238
239 tr = Nokogiri::XML::Node.new('tr', doc)239 tr = Nokogiri::XML::Node.new('tr', doc.document)
240 colspan = has_dd ? '' : ' colspan="2"' # handle <dt> without following <dt>240 colspan = has_dd ? '' : ' colspan="2"' # handle <dt> without following <dt>
241 tr.add_child("<th#{colspan}>#{dt.inner_html.sub(/:$/, '')}</th>")241 tr.add_child("<th#{colspan}>#{dt.inner_html.sub(/:$/, '')}</th>")
242 242