Sfoglia il codice sorgente

Update Rust documentation (1.28.0)

Thibaut Courouble 7 anni fa
parent
commit
73a41a1c99
2 ha cambiato i file con 10 aggiunte e 7 eliminazioni
  1. 5 2
      lib/docs/filters/rust/clean_html.rb
  2. 5 5
      lib/docs/scrapers/rust.rb

+ 5 - 2
lib/docs/filters/rust/clean_html.rb

@@ -5,7 +5,7 @@ module Docs
         puts subpath if at_css('#versioninfo')
 
         if slug.start_with?('book') ||  slug.start_with?('reference')
-          @doc = at_css('#content')
+          @doc = at_css('#content main')
         elsif slug == 'error-index'
           css('.error-undescribed').remove
 
@@ -30,7 +30,7 @@ module Docs
         css('.rusttest', '.test-arrow', 'hr').remove
 
         css('a.header').each do |node|
-          node.first_element_child['id'] = node['name']
+          node.first_element_child['id'] = node['name'] || node['id']
           node.before(node.children).remove
         end
 
@@ -62,6 +62,9 @@ module Docs
           node['data-language'] = 'rust' if node['class'] && node['class'].include?('rust')
         end
 
+        doc.first_element_child.name = 'h1' if doc.first_element_child.name = 'h2'
+        at_css('h1').content = 'Rust Documentation' if root_page?
+
         doc
       end
     end

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

@@ -1,9 +1,9 @@
 module Docs
   class Rust < UrlScraper
     self.type = 'rust'
-    self.release = '1.26.0'
+    self.release = '1.28.0'
     self.base_url = 'https://doc.rust-lang.org/'
-    self.root_path = 'book/first-edition/index.html'
+    self.root_path = 'book/second-edition/index.html'
     self.initial_paths = %w(
       reference/introduction.html
       collections/index.html
@@ -17,13 +17,13 @@ module Docs
     html_filters.push 'rust/entries', 'rust/clean_html'
 
     options[:only_patterns] = [
-      /\Abook\/first-edition\//,
+      /\Abook\/second-edition\//,
       /\Areference\//,
       /\Acollections\//,
       /\Astd\// ]
 
-    options[:skip] = %w(book/first-edition/README.html)
-    options[:skip_patterns] = [/(?<!\.html)\z/]
+    options[:skip] = %w(book/second-edition/README.html)
+    options[:skip_patterns] = [/(?<!\.html)\z/, /\/print\.html/]
 
     options[:fix_urls] = ->(url) do
       url.sub! %r{(#{Rust.base_url}.+/)\z}, '\1index.html'