Unified · Split
| @@ -7,5 +7,5 @@ · 6 unmodified lines | ||
| 7 | 7 | div.stability { margin-bottom: 1em; } |
| 8 | 8 | em.stab, span.stab { @extend %label; } |
| 9 | 9 | em.stab.unstable, span.stab.unstable { @extend %label-orange; } |
| 10 | − .since { float: right; } | |
| 10 | + .since, .out-of-band { float: right; } | |
| 11 | 11 | } |
| @@ -2,21 +2,49 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Rust |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − if slug.start_with?('book') | |
| 6 | − book | |
| 7 | − elsif slug.start_with?('reference') || slug == 'error-index' | |
| 8 | − reference | |
| 5 | + puts subpath if at_css('#versioninfo') | |
| 6 | + | |
| 7 | + if slug.start_with?('book') || slug.start_with?('reference') | |
| 8 | + @doc = at_css('#content') | |
| 9 | + elsif slug == 'error-index' | |
| 10 | + css('.error-undescribed').remove | |
| 11 | + | |
| 12 | + css('.error-described').each do |node| | |
| 13 | + node.before(node.children).remove | |
| 14 | + end | |
| 9 | 15 | else |
| 10 | − api | |
| 16 | + @doc = at_css('#main') | |
| 17 | + | |
| 18 | + css('.toggle-wrapper').remove | |
| 19 | + | |
| 20 | + css('h1.fqn').each do |node| | |
| 21 | + node.content = node.at_css('.in-band').content | |
| 22 | + end | |
| 23 | + | |
| 24 | + css('.stability .stab').each do |node| | |
| 25 | + node.name = 'span' | |
| 26 | + node.content = node.content | |
| 27 | + end | |
| 11 | 28 | end |
| 12 | 29 | |
| 13 | 30 | css('.rusttest', '.test-arrow', 'hr').remove |
| 14 | 31 | |
| 32 | + css('a.header').each do |node| | |
| 33 | + node.first_element_child['id'] = node['name'] | |
| 34 | + node.before(node.children).remove | |
| 35 | + end | |
| 36 | + | |
| 15 | 37 | css('.docblock > h1').each { |node| node.name = 'h4' } |
| 16 | 38 | css('h2.section-header').each { |node| node.name = 'h3' } |
| 17 | 39 | css('h1.section-header').each { |node| node.name = 'h2' } |
| 18 | 40 | |
| 19 | − css('> .impl-items', '> .docblock').each do |node| | |
| 41 | + if at_css('h1 ~ h1') | |
| 42 | + css('h1 ~ h1', 'h2', 'h3').each do |node| | |
| 43 | + node.name = node.name.sub(/\d/) { |i| i.to_i + 1 } | |
| 44 | + end | |
| 45 | + end | |
| 46 | + | |
| 47 | + css('> .impl-items', '> .docblock', 'pre > pre').each do |node| | |
| 20 | 48 | node.before(node.children).remove |
| 21 | 49 | end |
| 22 | 50 | |
| @@ -36,33 +64,6 @@ module Docs · 13 unmodified lines | ||
| 36 | 64 | |
| 37 | 65 | doc |
| 38 | 66 | end |
| 39 | − | |
| 40 | − def book | |
| 41 | − @doc = at_css('#page') | |
| 42 | − end | |
| 43 | − | |
| 44 | − def reference | |
| 45 | − css('#versioninfo', '.error-undescribed').remove | |
| 46 | − | |
| 47 | − css('.error-described').each do |node| | |
| 48 | − node.before(node.children).remove | |
| 49 | − end | |
| 50 | − end | |
| 51 | − | |
| 52 | − def api | |
| 53 | − @doc = at_css('#main') | |
| 54 | − | |
| 55 | − css('.toggle-wrapper').remove | |
| 56 | − | |
| 57 | − css('h1.fqn').each do |node| | |
| 58 | − node.content = node.at_css('.in-band').content | |
| 59 | − end | |
| 60 | − | |
| 61 | − css('.stability .stab').each do |node| | |
| 62 | − node.name = 'span' | |
| 63 | − node.content = node.content | |
| 64 | − end | |
| 65 | − end | |
| 66 | 67 | end |
| 67 | 68 | end |
| 68 | 69 | end |
| @@ -2,10 +2,8 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Rust |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | − if slug.start_with?('book') | |
| 6 | − at_css("#toc a[href='#{File.basename(slug)}']").content | |
| 7 | − elsif slug.start_with?('reference') | |
| 8 | − 'Reference' | |
| 5 | + if slug.start_with?('book') || slug.start_with?('reference') | |
| 6 | + at_css("#sidebar a[href='#{File.basename(slug)}']").content | |
| 9 | 7 | elsif slug == 'error-index' |
| 10 | 8 | 'Compiler Errors' |
| 11 | 9 | else |
| @@ -37,16 +35,8 @@ module Docs · 25 unmodified lines | ||
| 37 | 35 | end |
| 38 | 36 | |
| 39 | 37 | def additional_entries |
| 40 | − if slug.start_with?('book') | |
| 38 | + if slug.start_with?('book') || slug.start_with?('reference') | |
| 41 | 39 | [] |
| 42 | − elsif slug.start_with?('reference') | |
| 43 | − css('#TOC > ul > li > a', '#TOC > ul > li > ul > li > a').map do |node| | |
| 44 | − name = node.content | |
| 45 | − name.sub! %r{(\d)\ }, '\1. ' | |
| 46 | − name.sub! '10.0.', '10.' | |
| 47 | − id = node['href'].remove('#') | |
| 48 | − [name, id] | |
| 49 | − end | |
| 50 | 40 | elsif slug == 'error-index' |
| 51 | 41 | css('.error-described h2.section-header').each_with_object [] do |node, entries| |
| 52 | 42 | entries << [node.content, node['id']] unless node.content.include?('Note:') |
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Rust < UrlScraper |
| 3 | 3 | self.type = 'rust' |
| 4 | − self.release = '1.16.0' | |
| 4 | + self.release = '1.17.0' | |
| 5 | 5 | self.base_url = 'https://doc.rust-lang.org/' |
| 6 | 6 | self.root_path = 'book/index.html' |
| 7 | 7 | self.initial_paths = %w( |
| 8 | − reference.html | |
| 8 | + reference/introduction.html | |
| 9 | 9 | collections/index.html |
| 10 | 10 | std/index.html |
| 11 | 11 | error-index.html) |
| @@ -18,6 +18,7 @@ module Docs · 6 unmodified lines | ||
| 18 | 18 | |
| 19 | 19 | options[:only_patterns] = [ |
| 20 | 20 | /\Abook\//, |
| 21 | + /\Areference\//, | |
| 21 | 22 | /\Acollections\//, |
| 22 | 23 | /\Astd\// ] |
| 23 | 24 | |