Unified · Split
| @@ -232,7 +232,7 @@ credits = [ · 231 unmodified lines | |||
| 232 | 'https://api.drupal.org/api/drupal/LICENSE.txt' | 232 | 'https://api.drupal.org/api/drupal/LICENSE.txt' |
| 233 | ], [ | 233 | ], [ |
| 234 | 'Electron', | 234 | 'Electron', |
| 235 | '2013-2017 GitHub Inc.', | 235 | '2013-2018 GitHub Inc.', |
| 236 | 'MIT', | 236 | 'MIT', |
| 237 | 'https://raw.githubusercontent.com/electron/electron/master/LICENSE' | 237 | 'https://raw.githubusercontent.com/electron/electron/master/LICENSE' |
| 238 | ], [ | 238 | ], [ |
| @@ -4,7 +4,7 @@ module Docs · 3 unmodified lines | |||
| 4 | def call | 4 | def call |
| 5 | css('.header-link', 'hr + .text-center', 'hr').remove | 5 | css('.header-link', 'hr + .text-center', 'hr').remove |
| 6 | 6 | ||
| 7 | css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list').each do |node| | 7 | css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list', '.sub-section').each do |node| |
| 8 | node.before(node.children).remove | 8 | node.before(node.children).remove |
| 9 | end | 9 | end |
| 10 | 10 | ||
| @@ -16,18 +16,26 @@ module Docs · 5 unmodified lines | |||
| 16 | end | 16 | end |
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | at_css('h2').name = 'h1' unless at_css('h1') | 19 | at_css('h2').name = 'h1' if !at_css('h1') && at_css('h2') |
| 20 | 20 | ||
| 21 | css('h3', 'h4', 'h5').each do |node| | 21 | css('h3', 'h4', 'h5').each do |node| |
| 22 | node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code') | 22 | node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code') |
| 23 | end if !at_css('h2') && at_css('h4') | 23 | end if !at_css('h2') && at_css('h4') |
| 24 | 24 | ||
| 25 | css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node| | ||
| 26 | node.before(node.children).remove | ||
| 27 | end | ||
| 28 | |||
| 25 | css('div.highlighter-rouge').each do |node| | 29 | css('div.highlighter-rouge').each do |node| |
| 26 | node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] | 30 | node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] |
| 27 | node.content = node.content.strip | 31 | node.content = node.content.strip |
| 28 | node.name = 'pre' | 32 | node.name = 'pre' |
| 29 | end | 33 | end |
| 30 | 34 | ||
| 35 | css('pre > code.hljs').each do |node| | ||
| 36 | node.parent['data-language'] = node['class'][/language-(\w+)/, 1] | ||
| 37 | end | ||
| 38 | |||
| 31 | css('.highlighter-rouge').remove_attr('class') | 39 | css('.highlighter-rouge').remove_attr('class') |
| 32 | 40 | ||
| 33 | css('pre').each do |node| | 41 | css('pre').each do |node| |
| @@ -2,6 +2,8 @@ module Docs · 1 unmodified line | |||
| 2 | class Electron | 2 | class Electron |
| 3 | class EntriesFilter < Docs::EntriesFilter | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | def get_name | 4 | def get_name |
| 5 | return 'API' if subpath == '/api' | ||
| 6 | |||
| 5 | name = at_css('h1, h2').content | 7 | name = at_css('h1, h2').content |
| 6 | name.remove! 'Class: ' | 8 | name.remove! 'Class: ' |
| 7 | name.remove! ' Object' | 9 | name.remove! ' Object' |
| @@ -12,11 +14,13 @@ module Docs · 4 unmodified lines | |||
| 12 | end | 14 | end |
| 13 | 15 | ||
| 14 | def get_type | 16 | def get_type |
| 15 | if subpath.start_with?('tutorial') || slug.in?(%w(glossary/ faq/)) | 17 | return 'API' if subpath == '/api' |
| 18 | |||
| 19 | if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq)) | ||
| 16 | 'Guides' | 20 | 'Guides' |
| 17 | elsif subpath.start_with?('development') | 21 | elsif subpath.start_with?('/development') |
| 18 | 'Guides: Development' | 22 | 'Guides: Development' |
| 19 | elsif slug.in?(%w(api/synopsis/ api/chrome-command-line-switches/)) | 23 | elsif subpath.in?(%w(/api/synopsis /api/chrome-command-line-switches)) |
| 20 | 'API' | 24 | 'API' |
| 21 | elsif at_css('h1, h2').content.include?(' Object') | 25 | elsif at_css('h1, h2').content.include?(' Object') |
| 22 | 'API: Objects' | 26 | 'API: Objects' |
| @@ -26,7 +30,7 @@ module Docs · 3 unmodified lines | |||
| 26 | end | 30 | end |
| 27 | 31 | ||
| 28 | def additional_entries | 32 | def additional_entries |
| 29 | return [] unless slug.start_with?('api/') | 33 | return [] unless subpath.start_with?('/api') |
| 30 | 34 | ||
| 31 | css('h3 > code', 'h4 > code').each_with_object [] do |node, entries| | 35 | css('h3 > code', 'h4 > code').each_with_object [] do |node, entries| |
| 32 | next if node.previous.try(:content).present? || node.next.try(:content).present? | 36 | next if node.previous.try(:content).present? || node.next.try(:content).present? |
| @@ -37,10 +41,6 @@ module Docs · 4 unmodified lines | |||
| 37 | entries << [name, node.parent['id']] unless name == self.name | 41 | entries << [name, node.parent['id']] unless name == self.name |
| 38 | end | 42 | end |
| 39 | end | 43 | end |
| 40 | |||
| 41 | def include_default_entry? | ||
| 42 | slug != 'api/' | ||
| 43 | end | ||
| 44 | end | 44 | end |
| 45 | end | 45 | end |
| 46 | end | 46 | end |
| @@ -1,25 +1,25 @@ | |||
| 1 | module Docs | 1 | module Docs |
| 2 | class Electron < UrlScraper | 2 | class Electron < UrlScraper |
| 3 | self.type = 'electron' | 3 | self.type = 'electron' |
| 4 | self.base_url = 'https://electron.atom.io/docs/' | 4 | self.base_url = 'https://electronjs.org/docs' |
| 5 | self.release = '1.7.9' | 5 | self.release = '1.8.2' |
| 6 | self.links = { | 6 | self.links = { |
| 7 | home: 'https://electron.atom.io/', | 7 | home: 'https://electronjs.org/', |
| 8 | code: 'https://github.com/electron/electron' | 8 | code: 'https://github.com/electron/electron' |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | html_filters.push 'electron/clean_html', 'electron/entries' | 11 | html_filters.push 'electron/clean_html', 'electron/entries' |
| 12 | 12 | ||
| 13 | options[:trailing_slash] = true | 13 | options[:trailing_slash] = false |
| 14 | options[:container] = '.page-section > .container, .page-section > .container-narrow' | 14 | options[:container] = '.page-section > .container, .page-section > .container-narrow' |
| 15 | options[:skip] = %w(guides/ development/ tutorial/ versions/ all/) | 15 | options[:skip] = %w(guides development tutorial versions all) |
| 16 | options[:skip_patterns] = [/\/history\z/] | ||
| 16 | options[:replace_paths] = { | 17 | options[:replace_paths] = { |
| 17 | 'api/web-view-tag/' => 'api/webview-tag/', | 18 | 'api/web-view-tag' => 'api/webview-tag' |
| 18 | 'api/web-view-tag' => 'api/webview-tag/' | ||
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | options[:attribution] = <<-HTML | 21 | options[:attribution] = <<-HTML |
| 22 | © 2013–2017 GitHub Inc.<br> | 22 | © 2013–2018 GitHub Inc.<br> |
| 23 | Licensed under the MIT license. | 23 | Licensed under the MIT license. |
| 24 | HTML | 24 | HTML |
| 25 | end | 25 | end |