ソースを参照

Update Rust documentation (1.71.0)

Fixes #1881.
Simon Legner 2 年 前
コミット
03dfcf56ef
2 ファイル変更9 行追加0 行削除
  1. 4 0
      lib/docs/filters/rust/clean_html.rb
  2. 5 0
      lib/docs/scrapers/rust.rb

+ 4 - 0
lib/docs/filters/rust/clean_html.rb

@@ -88,8 +88,12 @@ module Docs
         end
 
         css('pre').each do |node|
+          node.css('.where.fmt-newline').each do |node|
+            node.before("\n")
+          end
           node.content = node.content
           node['data-language'] = 'rust' if node['class'] && node['class'].include?('rust')
+          node['data-language'] = 'rust' if node.classes.include?('code-header')
         end
 
         doc.first_element_child.name = 'h1' if doc.first_element_child.name = 'h2'

+ 5 - 0
lib/docs/scrapers/rust.rb

@@ -53,5 +53,10 @@ module Docs
     def process_response?(response)
       !(response.body =~ REDIRECT_RGX || response.body =~ NOT_FOUND_RGX || response.body.blank?)
     end
+
+    def parse(response) # Hook here because Nokogori removes whitespace from headings
+      response.body.gsub! %r{<h[1-6] class="code-header">}, '<pre class="code-header">'
+      super
+    end
   end
 end