mirror of https://github.com/freeCodeCamp/devdocs
parent
a70eaa9f5d
commit
61930288b8
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
Before Width: | Height: | Size: 27 KiB After Width: | Height: | Size: 29 KiB |
@ -0,0 +1,37 @@
|
||||
module Docs
|
||||
class Electron
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
css('.header-link', 'hr + .text-center', 'hr').remove
|
||||
|
||||
css('.grid', '.row', '.col-ms-12').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
css('h2 > a').each do |node|
|
||||
node.before(node.children).remove
|
||||
end if root_page?
|
||||
|
||||
at_css('h2').name = 'h1' unless at_css('h1')
|
||||
|
||||
css('h3', 'h4', 'h5').each do |node|
|
||||
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('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('.highlighter-rouge').remove_attr('class')
|
||||
|
||||
css('pre').each do |node|
|
||||
node.content = node.content
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,46 @@
|
||||
module Docs
|
||||
class Electron
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
def get_name
|
||||
name = at_css('h1, h2').content
|
||||
name.remove! 'Class: '
|
||||
name.remove! ' Object'
|
||||
name.remove! ' Function'
|
||||
name.remove! ' Option'
|
||||
name.remove! ' Tag'
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
if subpath.start_with?('tutorial') || slug.in?(%w(glossary/ faq/))
|
||||
'Guides'
|
||||
elsif subpath.start_with?('development')
|
||||
'Guides: Development'
|
||||
elsif slug.in?(%w(api/synopsis/ api/chrome-command-line-switches/))
|
||||
'API'
|
||||
elsif at_css('h1, h2').content.include?(' Object')
|
||||
'API: Objects'
|
||||
else
|
||||
name
|
||||
end
|
||||
end
|
||||
|
||||
def additional_entries
|
||||
return [] unless slug.start_with?('api/')
|
||||
|
||||
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.sub! %r{\(.*\)}, '()'
|
||||
name.remove! 'new '
|
||||
name = "<webview #{name}>" if self.name == '<webview>' && !name.start_with?('<webview>')
|
||||
entries << [name, node.parent['id']] unless name == self.name
|
||||
end
|
||||
end
|
||||
|
||||
def include_default_entry?
|
||||
slug != 'api/'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,26 @@
|
||||
module Docs
|
||||
class Electron < UrlScraper
|
||||
self.type = 'electron'
|
||||
self.base_url = 'https://electron.atom.io/docs/'
|
||||
self.release = '1.6.10'
|
||||
self.links = {
|
||||
home: 'https://electron.atom.io/',
|
||||
code: 'https://github.com/electron/electron'
|
||||
}
|
||||
|
||||
html_filters.push 'electron/clean_html', 'electron/entries'
|
||||
|
||||
options[:trailing_slash] = true
|
||||
options[:container] = '.page-section > .container, .page-section > .container-narrow'
|
||||
options[:skip] = %w(guides/ development/ tutorial/ versions/ all/)
|
||||
options[:replace_paths] = {
|
||||
'api/web-view-tag/' => 'api/webview-tag/',
|
||||
'api/web-view-tag' => 'api/webview-tag/'
|
||||
}
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© 2013–2017 GitHub Inc.<br>
|
||||
Licensed under the MIT license.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 532 B |
After Width: | Height: | Size: 1.2 KiB |
@ -0,0 +1 @@
|
||||
https://github.com/electron/electron.atom.io/tree/gh-pages/images
|
Loading…
Reference in new issue