Browse Source

Add Jest documentation

Thibaut Courouble 8 years ago
parent
commit
aa1be2f49d

BIN
assets/images/docs.png


BIN
assets/images/docs@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2017-05-14",
-    "New documentation: <a href=\"/liquid/\">Liquid</a>"
+    "New documentations: <a href=\"/jest/\">Jest</a> and <a href=\"/liquid/\">Liquid</a>"
   ], [
     "2017-04-30",
     "New documentation: <a href=\"/openjdk/\">OpenJDK</a>"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -283,6 +283,11 @@ credits = [
     '2015 InfluxData, Inc.',
     'MIT',
     'https://github.com/influxdata/docs.influxdata.com/blob/master/LICENSE'
+  ], [
+    'Jest',
+    '2014-present Facebook Inc.',
+    'BSD',
+    'https://raw.githubusercontent.com/facebook/jest/master/LICENSE'
   ], [
     'jQuery',
     'Packt Publishing<br>&copy; jQuery Foundation and other contributors',

+ 1 - 0
assets/javascripts/views/pages/simple.coffee

@@ -28,6 +28,7 @@ app.views.ExpressPage =
 app.views.GoPage =
 app.views.ImmutablePage =
 app.views.InfluxdataPage =
+app.views.JestPage =
 app.views.KnockoutPage =
 app.views.KotlinPage =
 app.views.LaravelPage =

+ 1 - 0
assets/stylesheets/global/_icons.scss

@@ -43,6 +43,7 @@
 %icon-clipboard-white       { background-position: -1rem -2rem; }
 %icon-close-white           { background-position: -2rem -2rem; }
 
+._icon-jest:before          { background-position: 0 0; }
 ._icon-liquid:before        { background-position: -1rem 0; }
 ._icon-openjdk:before       { background-position: -2rem 0; }
 ._icon-codeceptjs:before    { background-position: -3rem 0; }

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

@@ -28,6 +28,7 @@
 ._haxe,
 ._immutable,
 ._influxdata,
+._jest,
 ._less,
 ._lodash,
 ._marionette,

+ 29 - 0
lib/docs/filters/jest/clean_html.rb

@@ -0,0 +1,29 @@
+module Docs
+  class Jest
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.mainContainer .post')
+
+        at_css('h1').content = 'Jest' if root_page?
+
+        css('.edit-page-link', '.hash-link', 'hr').remove
+
+        css('.postHeader', 'article', 'div:not([class])').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('.anchor[name]').each do |node|
+          node.parent['id'] = node['name']
+          node.remove
+        end
+
+        css('pre').each do |node|
+          node['data-language'] = node['class'][/language-(\w+)/, 1]
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 35 - 0
lib/docs/filters/jest/entries.rb

@@ -0,0 +1,35 @@
+module Docs
+  class Jest
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        at_css('.mainContainer h1').content
+      end
+
+      def get_type
+        type = at_css('.navItemActive').ancestors('.navGroup').first.at_css('h3').content
+
+        if type == 'Introduction'
+          'Guides: Introduction'
+        elsif type == 'API Reference'
+          self.name
+        else
+          type
+        end
+      end
+
+      def additional_entries
+        return [] unless !root_page? && self.type == self.name # api page
+
+        at_css('.mainContainer ul').css('li > a').map do |node|
+          name = node.at_css('code').content.strip
+          name.sub! %r{\(.*\)}, '()'
+          name.remove! %r{[\s=<].*}
+          name.prepend 'jest ' if name.start_with?('--')
+          name.prepend 'Config: ' if slug == 'configuration'
+          id = node['href'].remove('#')
+          [name, id]
+        end
+      end
+    end
+  end
+end

+ 21 - 0
lib/docs/scrapers/jest.rb

@@ -0,0 +1,21 @@
+module Docs
+  class Jest < UrlScraper
+    self.type = 'jest'
+    self.release = '20.0.1'
+    self.base_url = 'https://facebook.github.io/jest/docs/en/'
+    self.root_path = 'getting-started.html'
+    self.links = {
+      home: 'https://facebook.github.io/jest/',
+      code: 'https://github.com/facebook/jest'
+    }
+
+    html_filters.push 'jest/entries', 'jest/clean_html'
+
+    options[:container] = '.docMainWrapper'
+
+    options[:attribution] = <<-HTML
+      &copy; 2014&ndash;present Facebook Inc.<br>
+      Licensed under the BSD License.
+    HTML
+  end
+end

BIN
public/icons/docs/jest/16.png


BIN
public/icons/docs/jest/16@2x.png


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

@@ -0,0 +1 @@
+https://github.com/facebook/jest/tree/master/website/src/jest/img