Unified · Split
Binary file not shown.
Binary file not shown.
| @@ -7,7 +7,7 @@ class app.collections.Types extends app.Collection · 6 unmodified lines | |||
| 7 | (result[@_groupFor(type)] ||= []).push(type) | 7 | (result[@_groupFor(type)] ||= []).push(type) |
| 8 | result.filter (e) -> e.length > 0 | 8 | result.filter (e) -> e.length > 0 |
| 9 | 9 | ||
| 10 | GUIDES_RGX = /guide|tutorial|getting\ started/i | 10 | GUIDES_RGX = /guide|tutorial|reference|getting\ started/i |
| 11 | 11 | ||
| 12 | _groupFor: (type) -> | 12 | _groupFor: (type) -> |
| 13 | if GUIDES_RGX.test(type.name) | 13 | if GUIDES_RGX.test(type.name) |
| @@ -1,5 +1,8 @@ | |||
| 1 | [ | 1 | [ |
| 2 | [ | 2 | [ |
| 3 | "2015-05-24", | ||
| 4 | "New <a href=\"/rust/\">Rust</a> documentation" | ||
| 5 | ], [ | ||
| 3 | "2015-04-26", | 6 | "2015-04-26", |
| 4 | "New <a href=\"/apache_http_server/\">Apache HTTP Server</a> and <a href=\"/npm/\">npm</a> documentations" | 7 | "New <a href=\"/apache_http_server/\">Apache HTTP Server</a> and <a href=\"/npm/\">npm</a> documentations" |
| 5 | ], [ | 8 | ], [ |
| @@ -0,0 +1,6 @@ | |||
| 1 | #= require views/pages/base | ||
| 2 | |||
| 3 | class app.views.RustPage extends app.views.BasePage | ||
| 4 | afterRender: -> | ||
| 5 | @highlightCode @findAll('pre.rust'), 'rust' | ||
| 6 | return | ||
| @@ -62,6 +62,7 @@ · 61 unmodified lines | |||
| 62 | 'pages/requirejs', | 62 | 'pages/requirejs', |
| 63 | 'pages/rethinkdb', | 63 | 'pages/rethinkdb', |
| 64 | 'pages/rfc', | 64 | 'pages/rfc', |
| 65 | 'pages/rust', | ||
| 65 | 'pages/socketio', | 66 | 'pages/socketio', |
| 66 | 'pages/sphinx', | 67 | 'pages/sphinx', |
| 67 | 'pages/underscore', | 68 | 'pages/underscore', |
| @@ -62,6 +62,7 @@ · 61 unmodified lines | |||
| 62 | 'pages/requirejs', | 62 | 'pages/requirejs', |
| 63 | 'pages/rethinkdb', | 63 | 'pages/rethinkdb', |
| 64 | 'pages/rfc', | 64 | 'pages/rfc', |
| 65 | 'pages/rust', | ||
| 65 | 'pages/socketio', | 66 | 'pages/socketio', |
| 66 | 'pages/sphinx', | 67 | 'pages/sphinx', |
| 67 | 'pages/underscore', | 68 | 'pages/underscore', |
| @@ -65,7 +65,7 @@ · 64 unmodified lines | |||
| 65 | ._icon-go:before { background-position: -1rem -4rem; } | 65 | ._icon-go:before { background-position: -1rem -4rem; } |
| 66 | ._icon-express:before { background-position: -2rem -4rem; } | 66 | ._icon-express:before { background-position: -2rem -4rem; } |
| 67 | ._icon-grunt:before { background-position: -3rem -4rem; } | 67 | ._icon-grunt:before { background-position: -3rem -4rem; } |
| 68 | 68 | ._icon-rust:before { background-position: -4rem -4rem; @extend %darkIconFix !optional; } | |
| 69 | ._icon-laravel:before { background-position: -5rem -4rem; } | 69 | ._icon-laravel:before { background-position: -5rem -4rem; } |
| 70 | ._icon-haskell:before { background-position: -6rem -4rem; } | 70 | ._icon-haskell:before { background-position: -6rem -4rem; } |
| 71 | ._icon-requirejs:before { background-position: -7rem -4rem; } | 71 | ._icon-requirejs:before { background-position: -7rem -4rem; } |
| @@ -0,0 +1,10 @@ | |||
| 1 | ._rust { | ||
| 2 | @extend %simple; | ||
| 3 | |||
| 4 | h4 { @extend %block-label; } | ||
| 5 | .docblock { margin-left: 1em; } | ||
| 6 | |||
| 7 | div.stability { margin-bottom: 1em; } | ||
| 8 | em.stab, span.stab { @extend %label; } | ||
| 9 | em.stab.unstable, span.stab.unstable { @extend %label-orange; } | ||
| 10 | } | ||
| @@ -0,0 +1,63 @@ | |||
| 1 | module Docs | ||
| 2 | class Rust | ||
| 3 | class CleanHtmlFilter < Filter | ||
| 4 | def call | ||
| 5 | if slug.start_with?('book') | ||
| 6 | book | ||
| 7 | elsif slug.start_with?('reference') | ||
| 8 | reference | ||
| 9 | else | ||
| 10 | api | ||
| 11 | end | ||
| 12 | |||
| 13 | css('.rusttest', 'hr').remove | ||
| 14 | |||
| 15 | css('.docblock > h1').each { |node| node.name = 'h4' } | ||
| 16 | css('h2.section-header').each { |node| node.name = 'h3' } | ||
| 17 | css('h1.section-header').each { |node| node.name = 'h2' } | ||
| 18 | |||
| 19 | css('> .impl-items', '> .docblock').each do |node| | ||
| 20 | node.before(node.children).remove | ||
| 21 | end | ||
| 22 | |||
| 23 | css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a', 'h5 > a').each do |node| | ||
| 24 | node.before(node.children).remove | ||
| 25 | end | ||
| 26 | |||
| 27 | css('pre > code').each do |node| | ||
| 28 | node.parent['class'] = node['class'] | ||
| 29 | node.before(node.children).remove | ||
| 30 | end | ||
| 31 | |||
| 32 | css('pre').each do |node| | ||
| 33 | node.content = node.content | ||
| 34 | end | ||
| 35 | |||
| 36 | doc | ||
| 37 | end | ||
| 38 | |||
| 39 | def book | ||
| 40 | @doc = at_css('#page') | ||
| 41 | end | ||
| 42 | |||
| 43 | def reference | ||
| 44 | css('#versioninfo').remove | ||
| 45 | end | ||
| 46 | |||
| 47 | def api | ||
| 48 | @doc = at_css('#main') | ||
| 49 | |||
| 50 | css('.toggle-wrapper').remove | ||
| 51 | |||
| 52 | css('h1.fqn').each do |node| | ||
| 53 | node.content = node.at_css('.in-band').content | ||
| 54 | end | ||
| 55 | |||
| 56 | css('.stability .stab').each do |node| | ||
| 57 | node.name = 'span' | ||
| 58 | node.content = node.content | ||
| 59 | end | ||
| 60 | end | ||
| 61 | end | ||
| 62 | end | ||
| 63 | end | ||
| @@ -0,0 +1,56 @@ | |||
| 1 | module Docs | ||
| 2 | class Rust | ||
| 3 | class EntriesFilter < Docs::EntriesFilter | ||
| 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' | ||
| 9 | else | ||
| 10 | name = at_css('h1.fqn .in-band').content.remove(/\A.+\s/) | ||
| 11 | mod = slug.split('/').first | ||
| 12 | name.prepend("#{mod}::") unless name.start_with?(mod) | ||
| 13 | name | ||
| 14 | end | ||
| 15 | end | ||
| 16 | |||
| 17 | PRIMITIVE_SLUG = /\A(\w+)\/(primitive)\./ | ||
| 18 | |||
| 19 | def get_type | ||
| 20 | if slug.start_with?('book') | ||
| 21 | 'Guide' | ||
| 22 | elsif slug.start_with?('reference') | ||
| 23 | 'Reference' | ||
| 24 | else | ||
| 25 | path = name.split('::') | ||
| 26 | heading = at_css('h1.fqn .in-band').content.strip | ||
| 27 | if path.length > 2 || (path.length == 2 && (heading.start_with?('Module') || heading.start_with?('Primitive'))) | ||
| 28 | path[0..1].join('::') | ||
| 29 | else | ||
| 30 | path[0] | ||
| 31 | end | ||
| 32 | end | ||
| 33 | end | ||
| 34 | |||
| 35 | def additional_entries | ||
| 36 | if slug.start_with?('book') | ||
| 37 | [] | ||
| 38 | elsif slug.start_with?('reference') | ||
| 39 | css('#TOC > ul > li > a', '#TOC > ul > li > ul > li > a').map do |node| | ||
| 40 | name = node.content | ||
| 41 | name.sub! %r{(\d)\ }, '\1. ' | ||
| 42 | name.sub! '10.0.', '10.' | ||
| 43 | id = node['href'].remove('#') | ||
| 44 | [name, id] | ||
| 45 | end | ||
| 46 | else | ||
| 47 | css('#methods + * + div > .method', '#required-methods + div > .method', '#provided-methods + div > .method').map do |node| | ||
| 48 | name = node.at_css('.fnname').content | ||
| 49 | name.prepend "#{self.name}::" | ||
| 50 | [name, node['id']] | ||
| 51 | end | ||
| 52 | end | ||
| 53 | end | ||
| 54 | end | ||
| 55 | end | ||
| 56 | end | ||
| @@ -0,0 +1,48 @@ | |||
| 1 | module Docs | ||
| 2 | class Rust < UrlScraper | ||
| 3 | self.type = 'rust' | ||
| 4 | self.version = '1.0.0' | ||
| 5 | self.base_url = 'http://doc.rust-lang.org/' | ||
| 6 | self.root_path = 'book/index.html' | ||
| 7 | self.initial_paths = %w( | ||
| 8 | reference.html | ||
| 9 | collections/index.html | ||
| 10 | std/index.html | ||
| 11 | unicode/index.html) | ||
| 12 | self.links = { | ||
| 13 | home: 'http://www.rust-lang.org/', | ||
| 14 | code: 'https://github.com/rust-lang/rust' | ||
| 15 | } | ||
| 16 | |||
| 17 | html_filters.push 'rust/entries', 'rust/clean_html' | ||
| 18 | |||
| 19 | options[:only_patterns] = [ | ||
| 20 | /\Abook\//, | ||
| 21 | /\Acollections\//, | ||
| 22 | /\Astd\//, | ||
| 23 | /\Aunicode\// ] | ||
| 24 | |||
| 25 | options[:skip] = %w(book/README.html) | ||
| 26 | options[:skip_patterns] = [/(?<!\.html)\z/] | ||
| 27 | |||
| 28 | options[:fix_urls] = ->(url) do | ||
| 29 | url.sub! %r{(#{Rust.base_url}.+/)\z}, '\1index.html' | ||
| 30 | url.sub! '/unicode/u_str', '/unicode/str/' | ||
| 31 | url | ||
| 32 | end | ||
| 33 | |||
| 34 | options[:attribution] = <<-HTML | ||
| 35 | © 2011-2015 The Rust Project Developers<br> | ||
| 36 | Licensed under the Apache License, Version 2.0 or the MIT license, at your option. | ||
| 37 | HTML | ||
| 38 | |||
| 39 | private | ||
| 40 | |||
| 41 | REDIRECT_RGX = /http-equiv="refresh"/i | ||
| 42 | NOT_FOUND_RGX = /<title>Not Found<\/title>/ | ||
| 43 | |||
| 44 | def process_response?(response) | ||
| 45 | !(response.body =~ REDIRECT_RGX || response.body =~ NOT_FOUND_RGX || response.body.blank?) | ||
| 46 | end | ||
| 47 | end | ||
| 48 | end | ||
Binary file not shown.
Binary file not shown.
| @@ -0,0 +1 @@ | |||
| 1 | https://github.com/rust-lang/rust-www/tree/8347e870e3b09824ef9137fa9146ef7d21fec3d6/logos | ||