Unified · Split
| @@ -1,3 +1,5 @@ | ||
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 1 | 3 | module Docs |
| 2 | 4 | class Rust |
| 3 | 5 | class CleanHtmlFilter < Filter |
| @@ -74,10 +76,10 @@ module Docs · 70 unmodified lines | ||
| 74 | 76 | node.remove |
| 75 | 77 | end |
| 76 | 78 | |
| 77 | − css('h2 .important-traits', 'h3 .important-traits', 'h4 .important-traits').each do |node| | |
| 79 | + css('.important-traits').to_a.each_with_index do |node, index| | |
| 78 | 80 | content = node.at_css('.content.hidden .content') |
| 79 | 81 | node.at_css('.content.hidden').replace(content) if content |
| 80 | − node.parent.after(node) | |
| 82 | + node.parent.after(node) if node.parent.name.in?(%(h2 h3 h4)) | |
| 81 | 83 | end |
| 82 | 84 | |
| 83 | 85 | css('code.content').each do |node| |
| @@ -43,13 +43,12 @@ module Docs · 42 unmodified lines | ||
| 43 | 43 | end |
| 44 | 44 | else |
| 45 | 45 | css('.method') |
| 46 | − .select {|node| !node.at_css('.fnname').nil?} | |
| 47 | − .map {|node| | |
| 48 | − name = node.at_css('.fnname').content | |
| 46 | + .each_with_object({}) { |node, entries| | |
| 47 | + name = node.at_css('.fnname').try(:content) | |
| 48 | + next unless name | |
| 49 | 49 | name.prepend "#{self.name}::" |
| 50 | − [name, node['id']] | |
| 51 | − } | |
| 52 | − .uniq {|item| item[0]} | |
| 50 | + entries[name] ||= [name, node['id']] | |
| 51 | + }.values | |
| 53 | 52 | end |
| 54 | 53 | end |
| 55 | 54 | end |
| @@ -1,7 +1,9 @@ | ||
| 1 | +# frozen_string_literal: true | |
| 2 | + | |
| 1 | 3 | module Docs |
| 2 | 4 | class Rust < UrlScraper |
| 3 | 5 | self.type = 'rust' |
| 4 | − self.release = '1.29.1' | |
| 6 | + self.release = '1.30.1' | |
| 5 | 7 | self.base_url = 'https://doc.rust-lang.org/' |
| 6 | 8 | self.root_path = 'book/second-edition/index.html' |
| 7 | 9 | self.initial_paths = %w( |
| @@ -28,6 +30,7 @@ module Docs · 20 unmodified lines | ||
| 28 | 30 | options[:fix_urls] = ->(url) do |
| 29 | 31 | url.sub! %r{(#{Rust.base_url}.+/)\z}, '\1index.html' |
| 30 | 32 | url.sub! '/unicode/u_str', '/unicode/str/' |
| 33 | + url.sub! '/std/std/', '/std/' | |
| 31 | 34 | url |
| 32 | 35 | end |
| 33 | 36 | |