Unified · Split
| @@ -2,51 +2,17 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Electron |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | − css('.header-link', 'hr + .text-center', 'hr', '.docs__actions-bar').remove | |
| 5 | + @doc = at_css(".markdown") | |
| 6 | 6 | |
| 7 | − css('.announcement-banner-contrast').remove | |
| 7 | + 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| | |
| 10 | − node.before(node.children).remove | |
| 11 | − end | |
| 9 | + css(".theme-doc-toc-desktop").remove | |
| 12 | 10 | |
| 13 | − if root_page? | |
| 14 | − doc.child.before('<h1>Electron Documentation</h1>') | |
| 11 | + css(".theme-doc-toc-mobile").remove | |
| 15 | 12 | |
| 16 | − css("div.subtron, div.py-6").remove | |
| 13 | + css(".clean-btn").remove | |
| 17 | 14 | |
| 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 | |
| 50 | 16 | |
| 51 | 17 | doc |
| 52 | 18 | end |
| @@ -3,7 +3,6 @@ module Docs · 2 unmodified lines | ||
| 3 | 3 | class EntriesFilter < Docs::EntriesFilter |
| 4 | 4 | def get_name |
| 5 | 5 | return 'API' if subpath == '/api' |
| 6 | − return 'Structures' if slug == 'api/structures' | |
| 7 | 6 | |
| 8 | 7 | name = at_css('h1, h2').content |
| 9 | 8 | name.remove! 'Class: ' |
| @@ -15,7 +14,7 @@ module Docs · 5 unmodified lines | ||
| 15 | 14 | end |
| 16 | 15 | |
| 17 | 16 | def get_type |
| 18 | − return 'API' if subpath == '/api' || slug == 'api/structures' | |
| 17 | + return 'API' if subpath == '/api' | |
| 19 | 18 | |
| 20 | 19 | if subpath.start_with?('/tutorial') || subpath.in?(%w(/glossary /faq)) |
| 21 | 20 | 'Guides' |
| @@ -34,7 +33,6 @@ module Docs · 12 unmodified lines | ||
| 34 | 33 | return [] unless subpath.start_with?('/api') |
| 35 | 34 | |
| 36 | 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 | 36 | name = node.content |
| 39 | 37 | name.sub! %r{\(.*\)}, '()' |
| 40 | 38 | name.remove! 'new ' |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | module Docs |
| 2 | 2 | class Electron < UrlScraper |
| 3 | 3 | 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' | |
| 6 | 6 | self.links = { |
| 7 | 7 | home: 'https://www.electronjs.org/', |
| 8 | 8 | code: 'https://github.com/electron/electron' |
| @@ -15,7 +15,6 @@ module Docs · 6 unmodified lines | ||
| 15 | 15 | options[:skip] = %w(guides development tutorial versions all) |
| 16 | 16 | options[:skip_patterns] = [ |
| 17 | 17 | /\/history\z/, |
| 18 | − /\/latest/ # beta site | |
| 19 | 18 | ] |
| 20 | 19 | options[:replace_paths] = { |
| 21 | 20 | 'api/web-view-tag' => 'api/webview-tag' |
| @@ -27,8 +26,8 @@ module Docs · 5 unmodified lines | ||
| 27 | 26 | HTML |
| 28 | 27 | |
| 29 | 28 | 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]/, '') | |
| 32 | 31 | end |
| 33 | 32 | end |
| 34 | 33 | end |