Update Electron documentation (15.3.0)

pull/1663/head
Enoc 3 years ago
parent 5c3b7d14b4
commit 10c1fa61dc

@ -2,51 +2,17 @@ module Docs
class Electron class Electron
class CleanHtmlFilter < Filter class CleanHtmlFilter < Filter
def call def call
css('.header-link', 'hr + .text-center', 'hr', '.docs__actions-bar').remove @doc = at_css(".markdown")
css('.announcement-banner-contrast').remove css("header").before(at_css("h1"))
css('.grid', '.row', '.col-ms-12', 'ul.docs-list > ul.docs-list', '.sub-section').each do |node| css(".theme-doc-toc-desktop").remove
node.before(node.children).remove
end
if root_page?
doc.child.before('<h1>Electron Documentation</h1>')
css("div.subtron, div.py-6").remove
css('h2 > a').each do |node|
node.before(node.children).remove
end
else
@doc = doc.at_css('div.docs > div.markdown-body')
end
at_css('h2').name = 'h1' if !at_css('h1') && at_css('h2')
css('h3', 'h4', 'h5').each do |node| css(".theme-doc-toc-mobile").remove
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')
css('h1 > a', 'h2 > a', 'h3 > a', 'h4 > a').each do |node| css(".clean-btn").remove
node.before(node.children).remove
end
css('div.highlighter-rouge').each do |node|
node['data-language'] = node['class'][/language-(\w+)/, 1] if node['class']
node.content = node.content.strip
node.name = 'pre'
end
css('pre > code.hljs').each do |node| css("footer").remove
node.parent['data-language'] = node['class'][/language-(\w+)/, 1]
end
css('.highlighter-rouge').remove_attr('class')
css('pre').each do |node|
node.content = node.content
end
doc doc
end end

@ -3,7 +3,6 @@ module Docs
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
return 'API' if subpath == '/api' return 'API' if subpath == '/api'
return 'Structures' if slug == 'api/structures'
name = at_css('h1, h2').content name = at_css('h1, h2').content
name.remove! 'Class: ' name.remove! 'Class: '
@ -15,7 +14,7 @@ module Docs
end end
def get_type def get_type
return 'API' if subpath == '/api' || slug == 'api/structures' return 'API' if subpath == '/api'
if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq)) if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq))
'Guides' 'Guides'
@ -34,7 +33,6 @@ module Docs
return [] unless subpath.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?
name = node.content name = node.content
name.sub! %r{\(.*\)}, '()' name.sub! %r{\(.*\)}, '()'
name.remove! 'new ' name.remove! 'new '

@ -1,8 +1,8 @@
module Docs module Docs
class Electron < UrlScraper class Electron < UrlScraper
self.type = 'simple' self.type = 'simple'
self.base_url = 'https://www.electronjs.org/docs' self.base_url = 'https://www.electronjs.org/docs/latest'
self.release = '14.0.0' self.release = '15.3.0'
self.links = { self.links = {
home: 'https://www.electronjs.org/', home: 'https://www.electronjs.org/',
code: 'https://github.com/electron/electron' code: 'https://github.com/electron/electron'
@ -15,7 +15,6 @@ module Docs
options[:skip] = %w(guides development tutorial versions all) options[:skip] = %w(guides development tutorial versions all)
options[:skip_patterns] = [ options[:skip_patterns] = [
/\/history\z/, /\/history\z/,
/\/latest/ # beta site
] ]
options[:replace_paths] = { options[:replace_paths] = {
'api/web-view-tag' => 'api/webview-tag' 'api/web-view-tag' => 'api/webview-tag'
@ -27,8 +26,8 @@ module Docs
HTML HTML
def get_latest_version(opts) def get_latest_version(opts)
doc = fetch_doc('https://www.electronjs.org/docs', opts) doc = fetch_doc('https://www.electronjs.org/releases/stable', opts)
doc.at_css('.docs-version').content doc.at_css(".tag").content.gsub!(/[a-zA-Z]/, '')
end end
end end
end end

Loading…
Cancel
Save