Jelajahi Sumber

Add Electron documentation

Thibaut Courouble 8 tahun lalu
induk
melakukan
61930288b8

TEMPAT SAMPAH
assets/images/docs-2.png


TEMPAT SAMPAH
assets/images/docs-2@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2017-06-04",
-    "New documentation: <a href=\"/pug/\">Pug</a>"
+    "New documentations: <a href=\"/electron/\">Electron</a>, <a href=\"/pug/\">Pug</a>"
   ], [
     "2017-05-14",
     "New documentations: <a href=\"/jest/\">Jest</a>, <a href=\"/jasmine/\">Jasmine</a> and <a href=\"/liquid/\">Liquid</a>"

+ 8 - 3
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',

+ 1 - 0
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 =

+ 1 - 0
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; }

+ 1 - 0
assets/stylesheets/pages/_simple.scss

@@ -22,6 +22,7 @@
 ._chai,
 ._codeceptjs,
 ._docker,
+._electron,
 ._fish,
 ._flow,
 ._gnu,

+ 37 - 0
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

+ 46 - 0
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 = "<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

+ 26 - 0
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
+      &copy; 2013&ndash;2017 GitHub Inc.<br>
+      Licensed under the MIT license.
+    HTML
+  end
+end

TEMPAT SAMPAH
public/icons/docs/electron/16.png


TEMPAT SAMPAH
public/icons/docs/electron/16@2x.png


+ 1 - 0
public/icons/docs/electron/SOURCE

@@ -0,0 +1 @@
+https://github.com/electron/electron.atom.io/tree/gh-pages/images