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