Skip to content

Commit c382eaf

Browse files
committed
Update Electron documentation (1.8.2)
1 parent 2b210a3 commit c382eaf

4 files changed

Lines changed: 27 additions & 19 deletions

File tree

assets/javascripts/templates/pages/about_tmpl.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ credits = [
232232
'https://api.drupal.org/api/drupal/LICENSE.txt'
233233
], [
234234
'Electron',
235-
'2013-2017 GitHub Inc.',
235+
'2013-2018 GitHub Inc.',
236236
'MIT',
237237
'https://raw.githubusercontent.com/electron/electron/master/LICENSE'
238238
], [

lib/docs/filters/electron/clean_html.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class CleanHtmlFilter < Filter
44
def call
55
css('.header-link', 'hr + .text-center', 'hr').remove
66

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|
88
node.before(node.children).remove
99
end
1010

@@ -16,18 +16,26 @@ def call
1616
end
1717
end
1818

19-
at_css('h2').name = 'h1' unless at_css('h1')
19+
at_css('h2').name = 'h1' if !at_css('h1') && at_css('h2')
2020

2121
css('h3', 'h4', 'h5').each do |node|
2222
node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code')
2323
end if !at_css('h2') && at_css('h4')
2424

25+
css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node|
26+
node.before(node.children).remove
27+
end
28+
2529
css('div.highlighter-rouge').each do |node|
2630
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
2731
node.content = node.content.strip
2832
node.name = 'pre'
2933
end
3034

35+
css('pre > code.hljs').each do |node|
36+
node.parent['data-language'] = node['class'][/language-(\w+)/, 1]
37+
end
38+
3139
css('.highlighter-rouge').remove_attr('class')
3240

3341
css('pre').each do |node|

lib/docs/filters/electron/entries.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ module Docs
22
class Electron
33
class EntriesFilter < Docs::EntriesFilter
44
def get_name
5+
return 'API' if subpath == '/api'
6+
57
name = at_css('h1, h2').content
68
name.remove! 'Class: '
79
name.remove! ' Object'
@@ -12,11 +14,13 @@ def get_name
1214
end
1315

1416
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))
1620
'Guides'
17-
elsif subpath.start_with?('development')
21+
elsif subpath.start_with?('/development')
1822
'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))
2024
'API'
2125
elsif at_css('h1, h2').content.include?(' Object')
2226
'API: Objects'
@@ -26,7 +30,7 @@ def get_type
2630
end
2731

2832
def additional_entries
29-
return [] unless slug.start_with?('api/')
33+
return [] unless subpath.start_with?('/api')
3034

3135
css('h3 > code', 'h4 > code').each_with_object [] do |node, entries|
3236
next if node.previous.try(:content).present? || node.next.try(:content).present?
@@ -37,10 +41,6 @@ def additional_entries
3741
entries << [name, node.parent['id']] unless name == self.name
3842
end
3943
end
40-
41-
def include_default_entry?
42-
slug != 'api/'
43-
end
4444
end
4545
end
4646
end

lib/docs/scrapers/electron.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
module Docs
22
class Electron < UrlScraper
33
self.type = 'electron'
4-
self.base_url = 'https://electron.atom.io/docs/'
5-
self.release = '1.7.9'
4+
self.base_url = 'https://electronjs.org/docs'
5+
self.release = '1.8.2'
66
self.links = {
7-
home: 'https://electron.atom.io/',
7+
home: 'https://electronjs.org/',
88
code: 'https://github.com/electron/electron'
99
}
1010

1111
html_filters.push 'electron/clean_html', 'electron/entries'
1212

13-
options[:trailing_slash] = true
13+
options[:trailing_slash] = false
1414
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/]
1617
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'
1919
}
2020

2121
options[:attribution] = <<-HTML
22-
&copy; 2013&ndash;2017 GitHub Inc.<br>
22+
&copy; 2013&ndash;2018 GitHub Inc.<br>
2323
Licensed under the MIT license.
2424
HTML
2525
end

0 commit comments

Comments
 (0)