Unified · Split
| @@ -2,14 +2,17 @@ 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?('docs') ? book : api | 5 | slug.start_with?('reference') ? book : api |
| 6 | doc | 6 | doc |
| 7 | end | 7 | end |
| 8 | 8 | ||
| 9 | def book | 9 | def book |
| 10 | @doc = at_css('.page-inner section') | 10 | @doc = at_css('main article') |
| 11 | |||
| 12 | css('.headerlink').remove | ||
| 11 | 13 | ||
| 12 | css('pre > code').each do |node| | 14 | css('pre > code').each do |node| |
| 15 | node.parent['data-language'] = 'crystal' | ||
| 13 | node.parent['data-language'] = node['class'][/lang-(\w+)/, 1] if node['class'] | 16 | node.parent['data-language'] = node['class'][/lang-(\w+)/, 1] if node['class'] |
| 14 | node.parent.content = node.parent.content | 17 | node.parent.content = node.parent.content |
| 15 | end | 18 | end |
| @@ -2,10 +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?('docs/') | 5 | if slug.start_with?('reference/') |
| 6 | name = at_css('.page-inner h1').content.strip | 6 | name = at_css('main h1').content.strip |
| 7 | name.remove! '¶' | ||
| 7 | 8 | ||
| 8 | if slug.start_with?('docs/syntax_and_semantics') | 9 | if slug.start_with?('reference/syntax_and_semantics') |
| 9 | name.prepend "#{slug.split('/')[2].titleize}: " if slug.split('/').length > 3 | 10 | name.prepend "#{slug.split('/')[2].titleize}: " if slug.split('/').length > 3 |
| 10 | elsif slug.split('/').length > 1 | 11 | elsif slug.split('/').length > 1 |
| 11 | chapter = slug.split('/')[1].titleize.capitalize | 12 | chapter = slug.split('/')[1].titleize.capitalize |
| @@ -23,9 +24,9 @@ module Docs · 11 unmodified lines | |||
| 23 | def get_type | 24 | def get_type |
| 24 | return if root_page? | 25 | return if root_page? |
| 25 | 26 | ||
| 26 | if slug.start_with?('docs/syntax_and_semantics') | 27 | if slug.start_with?('reference/syntax_and_semantics') |
| 27 | 'Book: Language' | 28 | 'Book: Language' |
| 28 | elsif slug.start_with?('docs/') | 29 | elsif slug.start_with?('reference/') |
| 29 | 'Book' | 30 | 'Book' |
| 30 | else | 31 | else |
| 31 | hierarchy = at_css('.superclass-hierarchy') | 32 | hierarchy = at_css('.superclass-hierarchy') |
| @@ -2,7 +2,7 @@ module Docs · 1 unmodified line | |||
| 2 | class Crystal < UrlScraper | 2 | class Crystal < UrlScraper |
| 3 | self.type = 'crystal' | 3 | self.type = 'crystal' |
| 4 | self.base_url = 'https://crystal-lang.org/' | 4 | self.base_url = 'https://crystal-lang.org/' |
| 5 | self.initial_paths = %w(docs/index.html) | 5 | self.initial_paths = %w(reference/index.html) |
| 6 | self.links = { | 6 | self.links = { |
| 7 | home: 'https://crystal-lang.org/', | 7 | home: 'https://crystal-lang.org/', |
| 8 | code: 'https://github.com/crystal-lang/crystal' | 8 | code: 'https://github.com/crystal-lang/crystal' |
| @@ -11,7 +11,7 @@ module Docs · 2 unmodified lines | |||
| 11 | html_filters.push 'crystal/entries', 'crystal/clean_html' | 11 | html_filters.push 'crystal/entries', 'crystal/clean_html' |
| 12 | 12 | ||
| 13 | options[:attribution] = ->(filter) { | 13 | options[:attribution] = ->(filter) { |
| 14 | if filter.slug.start_with?('docs') | 14 | if filter.slug.start_with?('reference') |
| 15 | <<-HTML | 15 | <<-HTML |
| 16 | To the extent possible under law, the persons who contributed to this work | 16 | 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 | 17 | have waived<br>all copyright and related or neighboring rights to this work |
| @@ -29,12 +29,12 @@ module Docs · 11 unmodified lines | |||
| 29 | self.release = '0.36.1' | 29 | self.release = '0.36.1' |
| 30 | self.root_path = "api/#{release}/index.html" | 30 | self.root_path = "api/#{release}/index.html" |
| 31 | 31 | ||
| 32 | options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//] | 32 | options[:only_patterns] = [/\Aapi\/#{release}\//, /\Areference\//] |
| 33 | options[:skip_patterns] = [/debug/i] | 33 | options[:skip_patterns] = [/debug/i] |
| 34 | 34 | ||
| 35 | options[:replace_paths] = { | 35 | options[:replace_paths] = { |
| 36 | "api/#{release}/" => "api/#{release}/index.html", | 36 | "api/#{release}/" => "api/#{release}/index.html", |
| 37 | 'docs/' => 'docs/index.html' | 37 | 'reference/' => 'reference/index.html' |
| 38 | } | 38 | } |
| 39 | end | 39 | end |
| 40 | 40 | ||