Update Electron documentation (1.8.2)

pull/775/head
Thibaut Courouble 7 years ago
parent 2b210a306f
commit c382eaf3cb

@ -232,7 +232,7 @@ credits = [
'https://api.drupal.org/api/drupal/LICENSE.txt' 'https://api.drupal.org/api/drupal/LICENSE.txt'
], [ ], [
'Electron', 'Electron',
'2013-2017 GitHub Inc.', '2013-2018 GitHub Inc.',
'MIT', 'MIT',
'https://raw.githubusercontent.com/electron/electron/master/LICENSE' 'https://raw.githubusercontent.com/electron/electron/master/LICENSE'
], [ ], [

@ -4,7 +4,7 @@ module Docs
def call def call
css('.header-link', 'hr + .text-center', 'hr').remove css('.header-link', 'hr + .text-center', 'hr').remove
css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list').each do |node| css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list', '.sub-section').each do |node|
node.before(node.children).remove node.before(node.children).remove
end end
@ -16,18 +16,26 @@ module Docs
end end
end end
at_css('h2').name = 'h1' unless at_css('h1') at_css('h2').name = 'h1' if !at_css('h1') && at_css('h2')
css('h3', 'h4', 'h5').each do |node| css('h3', 'h4', 'h5').each do |node|
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code') node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code')
end if !at_css('h2') && at_css('h4') end if !at_css('h2') && at_css('h4')
css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node|
node.before(node.children).remove
end
css('div.highlighter-rouge').each do |node| css('div.highlighter-rouge').each do |node|
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class'] node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
node.content = node.content.strip node.content = node.content.strip
node.name = 'pre' node.name = 'pre'
end end
css('pre > code.hljs').each do |node|
node.parent['data-language'] = node['class'][/language-(\w+)/, 1]
end
css('.highlighter-rouge').remove_attr('class') css('.highlighter-rouge').remove_attr('class')
css('pre').each do |node| css('pre').each do |node|

@ -2,6 +2,8 @@ module Docs
class Electron class Electron
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
return 'API' if subpath == '/api'
name = at_css('h1, h2').content name = at_css('h1, h2').content
name.remove! 'Class: ' name.remove! 'Class: '
name.remove! ' Object' name.remove! ' Object'
@ -12,11 +14,13 @@ module Docs
end end
def get_type def get_type
if subpath.start_with?('tutorial') || slug.in?(%w(glossary/ faq/)) return 'API' if subpath == '/api'
if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq))
'Guides' 'Guides'
elsif subpath.start_with?('development') elsif subpath.start_with?('/development')
'Guides: Development' 'Guides: Development'
elsif slug.in?(%w(api/synopsis/ api/chrome-command-line-switches/)) elsif subpath.in?(%w(/api/synopsis /api/chrome-command-line-switches))
'API' 'API'
elsif at_css('h1, h2').content.include?(' Object') elsif at_css('h1, h2').content.include?(' Object')
'API: Objects' 'API: Objects'
@ -26,7 +30,7 @@ module Docs
end end
def additional_entries def additional_entries
return [] unless slug.start_with?('api/') return [] unless subpath.start_with?('/api')
css('h3 > code', 'h4 > code').each_with_object [] do |node, entries| css('h3 > code', 'h4 > code').each_with_object [] do |node, entries|
next if node.previous.try(:content).present? || node.next.try(:content).present? next if node.previous.try(:content).present? || node.next.try(:content).present?
@ -37,10 +41,6 @@ module Docs
entries << [name, node.parent['id']] unless name == self.name entries << [name, node.parent['id']] unless name == self.name
end end
end end
def include_default_entry?
slug != 'api/'
end
end end
end end
end end

@ -1,25 +1,25 @@
module Docs module Docs
class Electron < UrlScraper class Electron < UrlScraper
self.type = 'electron' self.type = 'electron'
self.base_url = 'https://electron.atom.io/docs/' self.base_url = 'https://electronjs.org/docs'
self.release = '1.7.9' self.release = '1.8.2'
self.links = { self.links = {
home: 'https://electron.atom.io/', home: 'https://electronjs.org/',
code: 'https://github.com/electron/electron' code: 'https://github.com/electron/electron'
} }
html_filters.push 'electron/clean_html', 'electron/entries' html_filters.push 'electron/clean_html', 'electron/entries'
options[:trailing_slash] = true options[:trailing_slash] = false
options[:container] = '.page-section > .container, .page-section > .container-narrow' options[:container] = '.page-section > .container, .page-section > .container-narrow'
options[:skip] = %w(guides/ development/ tutorial/ versions/ all/) options[:skip] = %w(guides development tutorial versions all)
options[:skip_patterns] = [/\/history\z/]
options[:replace_paths] = { options[:replace_paths] = {
'api/web-view-tag/' => 'api/webview-tag/', 'api/web-view-tag' => 'api/webview-tag'
'api/web-view-tag' => 'api/webview-tag/'
} }
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
&copy; 2013&ndash;2017 GitHub Inc.<br> &copy; 2013&ndash;2018 GitHub Inc.<br>
Licensed under the MIT license. Licensed under the MIT license.
HTML HTML
end end

Loading…
Cancel
Save