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