History

Update Electron documentation (15.3.0)

Enoc committed 4 years ago

Commit 10c1fa61 parent 5c3b7d13 files · +11 −48Browse files

Unified · Split

3 files
  1. lib/docs/filters/electron/clean_html.rb +6 −40
  2. lib/docs/filters/electron/entries.rb +1 −3
  3. lib/docs/scrapers/electron.rb +4 −5
lib/docs/filters/electron/clean_html.rb+6−40
@@ -2,51 +2,17 @@ module Docs · 1 unmodified line
22 class Electron
33 class CleanHtmlFilter < Filter
44 def call
5− css('.header-link', 'hr + .text-center', 'hr', '.docs__actions-bar').remove
5+ @doc = at_css(".markdown")
66
7− css('.announcement-banner-contrast').remove
7+ css("header").before(at_css("h1"))
88
9− css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list', '.sub-section').each do |node|
10− node.before(node.children).remove
11− end
9+ css(".theme-doc-toc-desktop").remove
1210
13− if root_page?
14− doc.child.before('<h1>Electron Documentation</h1>')
11+ css(".theme-doc-toc-mobile").remove
1512
16− css("div.subtron, div.py-6").remove
13+ css(".clean-btn").remove
1714
18− css('h2 > a').each do |node|
19− node.before(node.children).remove
20− end
21− else
22− @doc = doc.at_css('div.docs > div.markdown-body')
23− end
24−
25− at_css('h2').name = 'h1' if !at_css('h1') && at_css('h2')
26−
27− css('h3', 'h4', 'h5').each do |node|
28− node.name = node.name.sub(/\d/) { |i| i.to_i - 1 } unless node.name == 'h3' && node.at_css('code')
29− end if !at_css('h2') && at_css('h4')
30−
31− css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node|
32− node.before(node.children).remove
33− end
34−
35− css('div.highlighter-rouge').each do |node|
36− node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
37− node.content = node.content.strip
38− node.name = 'pre'
39− end
40−
41− css('pre > code.hljs').each do |node|
42− node.parent['data-language'] = node['class'][/language-(\w+)/, 1]
43− end
44−
45− css('.highlighter-rouge').remove_attr('class')
46−
47− css('pre').each do |node|
48− node.content = node.content
49− end
15+ css("footer").remove
5016
5117 doc
5218 end
lib/docs/filters/electron/entries.rb+1−3
@@ -3,7 +3,6 @@ module Docs · 2 unmodified lines
33 class EntriesFilter < Docs::EntriesFilter
44 def get_name
55 return 'API' if subpath == '/api'
6− return 'Structures' if slug == 'api/structures'
76
87 name = at_css('h1, h2').content
98 name.remove! 'Class: '
@@ -15,7 +14,7 @@ module Docs · 5 unmodified lines
1514 end
1615
1716 def get_type
18− return 'API' if subpath == '/api' || slug == 'api/structures'
17+ return 'API' if subpath == '/api'
1918
2019 if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq))
2120 'Guides'
@@ -34,7 +33,6 @@ module Docs · 12 unmodified lines
3433 return [] unless subpath.start_with?('/api')
3534
3635 css('h3 > code', 'h4 > code').each_with_object [] do |node, entries|
37− next if node.previous.try(:content).present? || node.next.try(:content).present?
3836 name = node.content
3937 name.sub! %r{\(.*\)}, '()'
4038 name.remove! 'new '
lib/docs/scrapers/electron.rb+4−5
@@ -1,8 +1,8 @@
11 module Docs
22 class Electron < UrlScraper
33 self.type = 'simple'
4− self.base_url = 'https://www.electronjs.org/docs'
5− self.release = '14.0.0'
4+ self.base_url = 'https://www.electronjs.org/docs/latest'
5+ self.release = '15.3.0'
66 self.links = {
77 home: 'https://www.electronjs.org/',
88 code: 'https://github.com/electron/electron'
@@ -15,7 +15,6 @@ module Docs · 6 unmodified lines
1515 options[:skip] = %w(guides development tutorial versions all)
1616 options[:skip_patterns] = [
1717 /\/history\z/,
18− /\/latest/ # beta site
1918 ]
2019 options[:replace_paths] = {
2120 'api/web-view-tag' => 'api/webview-tag'
@@ -27,8 +26,8 @@ module Docs · 5 unmodified lines
2726 HTML
2827
2928 def get_latest_version(opts)
30− doc = fetch_doc('https://www.electronjs.org/docs', opts)
31− doc.at_css('.docs-version').content
29+ doc = fetch_doc('https://www.electronjs.org/releases/stable', opts)
30+ doc.at_css(".tag").content.gsub!(/[a-zA-Z]/, '')
3231 end
3332 end
3433 end