Unified · Split
| @@ -204,7 +204,7 @@ credits = [ · 203 unmodified lines | ||
| 204 | 204 | 'https://raw.githubusercontent.com/apache/cordova-docs/master/LICENSE' |
| 205 | 205 | ], [ |
| 206 | 206 | 'Crystal', |
| 207 | − '2012-2021 Manas Technology Solutions', | |
| 207 | + '2012-2022 Manas Technology Solutions', | |
| 208 | 208 | 'Apache', |
| 209 | 209 | 'https://raw.githubusercontent.com/crystal-lang/crystal/master/LICENSE' |
| 210 | 210 | ], [ |
| @@ -2,7 +2,7 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Crystal |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − slug.start_with?('reference') ? book : api | |
| 5 | + current_url.path.start_with?('/reference/') ? book : api | |
| 6 | 6 | doc |
| 7 | 7 | end |
| 8 | 8 | |
| @@ -21,7 +21,7 @@ module Docs · 12 unmodified lines | ||
| 21 | 21 | def api |
| 22 | 22 | @doc = at_css('.main-content') |
| 23 | 23 | |
| 24 | − at_css('h1 + p').remove if root_page? | |
| 24 | + at_css('h1 + p').remove if current_url.path == "/api/#{release}/index.html" | |
| 25 | 25 | |
| 26 | 26 | css('.method-permalink', '.doc + br', 'hr', 'a > br', 'div + br').remove |
| 27 | 27 | |
| @@ -2,11 +2,11 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Crystal |
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | − if slug.start_with?('reference/') | |
| 5 | + if current_url.path.start_with?('/reference/') | |
| 6 | 6 | name = at_css('main h1').content.strip |
| 7 | 7 | name.remove! '¶' |
| 8 | 8 | |
| 9 | − if slug.start_with?('reference/syntax_and_semantics') | |
| 9 | + if current_url.path.start_with?('/reference/') && slug.match?('syntax_and_semantics') | |
| 10 | 10 | name.prepend "#{slug.split('/')[2].titleize}: " if slug.split('/').length > 3 |
| 11 | 11 | elsif slug.split('/').length > 1 |
| 12 | 12 | chapter = slug.split('/')[1].titleize.capitalize |
| @@ -15,6 +15,7 @@ module Docs · 2 unmodified lines | ||
| 15 | 15 | |
| 16 | 16 | name |
| 17 | 17 | else |
| 18 | + return at_css('h1').content.strip unless at_css('.type-name') | |
| 18 | 19 | name = at_css('.type-name').children.last.content.strip |
| 19 | 20 | name.remove! %r{\(.*\)} |
| 20 | 21 | name |
| @@ -22,11 +23,11 @@ module Docs · 1 unmodified line | ||
| 22 | 23 | end |
| 23 | 24 | |
| 24 | 25 | def get_type |
| 25 | − return if root_page? | |
| 26 | + return if current_url.path == "/api/#{release}/index.html" | |
| 26 | 27 | |
| 27 | − if slug.start_with?('reference/syntax_and_semantics') | |
| 28 | + if current_url.path.start_with?('/reference/') && slug.match?('syntax_and_semantics') | |
| 28 | 29 | 'Book: Language' |
| 29 | − elsif slug.start_with?('reference/') | |
| 30 | + elsif current_url.path.start_with?('/reference/') | |
| 30 | 31 | 'Book' |
| 31 | 32 | else |
| 32 | 33 | hierarchy = at_css('.superclass-hierarchy') |
| @@ -44,7 +45,7 @@ module Docs · 11 unmodified lines | ||
| 44 | 45 | end |
| 45 | 46 | |
| 46 | 47 | def additional_entries |
| 47 | − return [] unless slug.start_with?('api') | |
| 48 | + return [] unless current_url.path.start_with?('/api/') | |
| 48 | 49 | entries = [] |
| 49 | 50 | |
| 50 | 51 | css('.entry-detail[id$="class-method"]').each do |node| |
| @@ -1,8 +1,17 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Crystal < UrlScraper |
| 3 | + include MultipleBaseUrls | |
| 3 | 4 | self.type = 'crystal' |
| 4 | − self.base_url = 'https://crystal-lang.org/' | |
| 5 | − self.initial_paths = %w(reference/index.html) | |
| 5 | + self.release = '1.3.0' | |
| 6 | + self.base_urls = [ | |
| 7 | + "https://crystal-lang.org/api/#{release}/", | |
| 8 | + "https://crystal-lang.org/reference/#{release[0..2]}/", | |
| 9 | + ] | |
| 10 | + def initial_urls | |
| 11 | + [ "https://crystal-lang.org/api/#{self.class.release}/index.html", | |
| 12 | + "https://crystal-lang.org/reference/#{self.class.release[0..2]}/index.html" ] | |
| 13 | + end | |
| 14 | + | |
| 6 | 15 | self.links = { |
| 7 | 16 | home: 'https://crystal-lang.org/', |
| 8 | 17 | code: 'https://github.com/crystal-lang/crystal' |
| @@ -11,7 +20,7 @@ module Docs · 2 unmodified lines | ||
| 11 | 20 | html_filters.push 'crystal/entries', 'crystal/clean_html' |
| 12 | 21 | |
| 13 | 22 | options[:attribution] = ->(filter) { |
| 14 | − if filter.slug.start_with?('reference') | |
| 23 | + if filter.current_url.path.start_with?('/reference/') | |
| 15 | 24 | <<-HTML |
| 16 | 25 | To the extent possible under law, the persons who contributed to this work |
| 17 | 26 | have waived<br>all copyright and related or neighboring rights to this work |
| @@ -19,23 +28,12 @@ module Docs · 1 unmodified line | ||
| 19 | 28 | HTML |
| 20 | 29 | else |
| 21 | 30 | <<-HTML |
| 22 | − © 2012–2021 Manas Technology Solutions.<br> | |
| 31 | + © 2012–2022 Manas Technology Solutions.<br> | |
| 23 | 32 | Licensed under the Apache License, Version 2.0. |
| 24 | 33 | HTML |
| 25 | 34 | end |
| 26 | 35 | } |
| 27 | 36 | |
| 28 | − self.release = '1.2.1' | |
| 29 | − self.root_path = "api/#{release}/index.html" | |
| 30 | − | |
| 31 | − options[:only_patterns] = [/\Aapi\/#{release}\//, /\Areference\//] | |
| 32 | − options[:skip_patterns] = [/debug/i] | |
| 33 | − | |
| 34 | − options[:replace_paths] = { | |
| 35 | − "api/#{release}/" => "api/#{release}/index.html", | |
| 36 | − 'reference/' => 'reference/index.html' | |
| 37 | − } | |
| 38 | − | |
| 39 | 37 | def get_latest_version(opts) |
| 40 | 38 | doc = fetch_doc('https://crystal-lang.org/', opts) |
| 41 | 39 | doc.at_css('.latest-release').content.scan(/([0-9.]+)/)[0][0] |