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
2 class Electron2 class Electron
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 css('.header-link', 'hr + .text-center', 'hr', '.docs__actions-bar').remove5 @doc = at_css(".markdown")
6 6
7 css('.announcement-banner-contrast').remove7 css("header").before(at_css("h1"))
8 8
9 css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list', '.sub-section').each do |node|9 css(".theme-doc-toc-desktop").remove
10 node.before(node.children).remove
11 end
12 10
13 if root_page?11 css(".theme-doc-toc-mobile").remove
14 doc.child.before('<h1>Electron Documentation</h1>')
15 12
16 css("div.subtron, div.py-6").remove13 css(".clean-btn").remove
17 14
18 css('h2 > a').each do |node|15 css("footer").remove
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
50 16
51 doc17 doc
52 end18 end
lib/docs/filters/electron/entries.rb+1−3
@@ -3,7 +3,6 @@ module Docs · 2 unmodified lines
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 def get_name4 def get_name
5 return 'API' if subpath == '/api'5 return 'API' if subpath == '/api'
6 return 'Structures' if slug == 'api/structures'
7 6
8 name = at_css('h1, h2').content7 name = at_css('h1, h2').content
9 name.remove! 'Class: '8 name.remove! 'Class: '
@@ -15,7 +14,7 @@ module Docs · 5 unmodified lines
15 end14 end
16 15
17 def get_type16 def get_type
18 return 'API' if subpath == '/api' || slug == 'api/structures'17 return 'API' if subpath == '/api'
19 18
20 if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq))19 if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq))
21 'Guides'20 'Guides'
@@ -34,7 +33,6 @@ module Docs · 12 unmodified lines
34 return [] unless subpath.start_with?('/api')33 return [] unless subpath.start_with?('/api')
35 34
36 css('h3 > code', 'h4 > code').each_with_object [] do |node, entries|35 css('h3 > code', 'h4 > code').each_with_object [] do |node, entries|
37 next if node.previous.try(:content).present? || node.next.try(:content).present?
38 name = node.content36 name = node.content
39 name.sub! %r{\(.*\)}, '()'37 name.sub! %r{\(.*\)}, '()'
40 name.remove! 'new '38 name.remove! 'new '
lib/docs/scrapers/electron.rb+4−5
@@ -1,8 +1,8 @@
1module Docs1module Docs
2 class Electron < UrlScraper2 class Electron < UrlScraper
3 self.type = 'simple'3 self.type = 'simple'
4 self.base_url = 'https://www.electronjs.org/docs'4 self.base_url = 'https://www.electronjs.org/docs/latest'
5 self.release = '14.0.0'5 self.release = '15.3.0'
6 self.links = {6 self.links = {
7 home: 'https://www.electronjs.org/',7 home: 'https://www.electronjs.org/',
8 code: 'https://github.com/electron/electron'8 code: 'https://github.com/electron/electron'
@@ -15,7 +15,6 @@ module Docs · 6 unmodified lines
15 options[:skip] = %w(guides development tutorial versions all)15 options[:skip] = %w(guides development tutorial versions all)
16 options[:skip_patterns] = [16 options[:skip_patterns] = [
17 /\/history\z/,17 /\/history\z/,
18 /\/latest/ # beta site
19 ]18 ]
20 options[:replace_paths] = {19 options[:replace_paths] = {
21 'api/web-view-tag' => 'api/webview-tag'20 'api/web-view-tag' => 'api/webview-tag'
@@ -27,8 +26,8 @@ module Docs · 5 unmodified lines
27 HTML26 HTML
28 27
29 def get_latest_version(opts)28 def get_latest_version(opts)
30 doc = fetch_doc('https://www.electronjs.org/docs', opts)29 doc = fetch_doc('https://www.electronjs.org/releases/stable', opts)
31 doc.at_css('.docs-version').content30 doc.at_css(".tag").content.gsub!(/[a-zA-Z]/, '')
32 end31 end
33 end32 end
34end33end