diff --git a/assets/images/docs-2.png b/assets/images/docs-2.png index 827661fd..53352548 100644 Binary files a/assets/images/docs-2.png and b/assets/images/docs-2.png differ diff --git a/assets/images/docs-2@2x.png b/assets/images/docs-2@2x.png index edc4fa03..977564c5 100644 Binary files a/assets/images/docs-2@2x.png and b/assets/images/docs-2@2x.png differ diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index ea2659cb..4e428963 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,7 +1,7 @@ [ [ "2017-06-04", - "New documentation: Pug" + "New documentations: Electron, Pug" ], [ "2017-05-14", "New documentations: Jest, Jasmine and Liquid" diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 6036ce00..14f229c3 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -219,15 +219,20 @@ credits = [ 'GPLv2', 'https://api.drupal.org/api/drupal/LICENSE.txt' ], [ - 'Ember.js', - '2017 Yehuda Katz, Tom Dale and Ember.js contributors', + 'Electron', + '2013-2017 GitHub Inc.', 'MIT', - 'https://raw.githubusercontent.com/emberjs/ember.js/master/LICENSE' + 'https://raw.githubusercontent.com/electron/electron/master/LICENSE' ], [ 'Elixir', '2012-2017 Plataformatec', 'Apache', 'https://raw.githubusercontent.com/elixir-lang/elixir/master/LICENSE' + ], [ + 'Ember.js', + '2017 Yehuda Katz, Tom Dale and Ember.js contributors', + 'MIT', + 'https://raw.githubusercontent.com/emberjs/ember.js/master/LICENSE' ], [ 'Erlang', '2010-2017 Ericsson AB', diff --git a/assets/javascripts/views/pages/simple.coffee b/assets/javascripts/views/pages/simple.coffee index 91fd1c5c..c86c65f9 100644 --- a/assets/javascripts/views/pages/simple.coffee +++ b/assets/javascripts/views/pages/simple.coffee @@ -22,6 +22,7 @@ app.views.CrystalPage = app.views.D3Page = app.views.DockerPage = app.views.DrupalPage = +app.views.ElectronPage = app.views.ElixirPage = app.views.EmberPage = app.views.ErlangPage = diff --git a/assets/stylesheets/global/_icons.scss b/assets/stylesheets/global/_icons.scss index ff754bc8..1240941a 100644 --- a/assets/stylesheets/global/_icons.scss +++ b/assets/stylesheets/global/_icons.scss @@ -173,3 +173,4 @@ ._icon-love:before { background-position: -9rem -1rem; @extend %doc-icon-2; } ._icon-jasmine:before { background-position: 0 -2rem; @extend %doc-icon-2; } ._icon-pug:before { background-position: -1rem -2rem; @extend %doc-icon-2; } +._icon-electron:before { background-position: -2rem -2rem; @extend %doc-icon-2; } diff --git a/assets/stylesheets/pages/_simple.scss b/assets/stylesheets/pages/_simple.scss index 4b2ef274..6db17ba3 100644 --- a/assets/stylesheets/pages/_simple.scss +++ b/assets/stylesheets/pages/_simple.scss @@ -22,6 +22,7 @@ ._chai, ._codeceptjs, ._docker, +._electron, ._fish, ._flow, ._gnu, diff --git a/lib/docs/filters/electron/clean_html.rb b/lib/docs/filters/electron/clean_html.rb new file mode 100644 index 00000000..a29b876b --- /dev/null +++ b/lib/docs/filters/electron/clean_html.rb @@ -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 diff --git a/lib/docs/filters/electron/entries.rb b/lib/docs/filters/electron/entries.rb new file mode 100644 index 00000000..0f56e7e1 --- /dev/null +++ b/lib/docs/filters/electron/entries.rb @@ -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 = "" if self.name == '' && !name.start_with?('') + entries << [name, node.parent['id']] unless name == self.name + end + end + + def include_default_entry? + slug != 'api/' + end + end + end +end diff --git a/lib/docs/scrapers/electron.rb b/lib/docs/scrapers/electron.rb new file mode 100644 index 00000000..8a586dbb --- /dev/null +++ b/lib/docs/scrapers/electron.rb @@ -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.
+ Licensed under the MIT license. + HTML + end +end diff --git a/public/icons/docs/electron/16.png b/public/icons/docs/electron/16.png new file mode 100644 index 00000000..8a95c788 Binary files /dev/null and b/public/icons/docs/electron/16.png differ diff --git a/public/icons/docs/electron/16@2x.png b/public/icons/docs/electron/16@2x.png new file mode 100644 index 00000000..13f9ff0c Binary files /dev/null and b/public/icons/docs/electron/16@2x.png differ diff --git a/public/icons/docs/electron/SOURCE b/public/icons/docs/electron/SOURCE new file mode 100644 index 00000000..5186efcc --- /dev/null +++ b/public/icons/docs/electron/SOURCE @@ -0,0 +1 @@ +https://github.com/electron/electron.atom.io/tree/gh-pages/images