Jelajahi Sumber

Add Redux documentation

Thibaut Courouble 9 tahun lalu
induk
melakukan
7ab536743c

TEMPAT SAMPAH
assets/images/docs.png


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


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2016-07-24",
-    "New documentations: <a href=\"/julia/\">Julia</a> and <a href=\"/crystal/\">Crystal</a>"
+    "New documentations: <a href=\"/julia/\">Julia</a>, <a href=\"/crystal/\">Crystal</a> and <a href=\"/redux/\">Redux</a>"
   ], [
     "2016-07-03",
     "New documentations: <a href=\"/cmake/\">CMake</a> and <a href=\"/matplotlib/\">Matplotlib</a>"

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

@@ -435,6 +435,11 @@ credits = [
     '2009-2016 Salvatore Sanfilippo',
     'CC BY-SA',
     'https://creativecommons.org/licenses/by-sa/4.0/'
+  ], [
+    'Redux',
+    '2015-2016 Dan Abramov',
+    'MIT',
+    'https://raw.githubusercontent.com/reactjs/redux/master/LICENSE.md'
   ], [
     'RequireJS',
     'jQuery Foundation and other contributors',

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

@@ -37,6 +37,7 @@ app.views.PhpunitPage =
 app.views.PostgresPage =
 app.views.RamdaPage =
 app.views.ReactPage =
+app.views.ReduxPage =
 app.views.RethinkdbPage =
 app.views.RubydocPage =
 app.views.SinonPage =

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

@@ -132,6 +132,7 @@
 ._icon-q:before             { background-position: -5rem -8rem; }
 ._icon-crystal:before       { background-position: -6rem -8rem; @extend %darkIconFix !optional; }
 ._icon-julia:before         { background-position: -7rem -8rem; @extend %darkIconFix !optional; }
+._icon-redux:before         { background-position: -8rem -8rem; @extend %darkIconFix !optional; }
 ._icon-react_native:before  { background-position: 0 -9rem; }
 ._icon-phalcon:before       { background-position: -1rem -9rem; }
 ._icon-matplotlib:before    { background-position: -2rem -9rem; }

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

@@ -14,6 +14,7 @@
 
   p > code, li > code { @extend %label; }
   blockquote { @extend %note; }
+  blockquote > h4, blockquote > h5 { margin-top: .25rem; }
 }
 
 ._apache_pig,
@@ -29,6 +30,7 @@
 ._markdown,
 ._mocha,
 ._mongoose,
+._redux,
 ._sinon,
 ._typescript,
 ._webpack {

+ 38 - 0
lib/docs/filters/redux/clean_html.rb

@@ -0,0 +1,38 @@
+module Docs
+  class Redux
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.page-inner > section')
+
+        css('#edit-link', 'hr').remove
+
+        at_css('h2').name = 'h1' unless at_css('h1')
+
+        if root_page?
+          at_css('h1').content = 'Redux'
+
+          at_css('a[href="https://www.npmjs.com/package/redux"]').parent.remove
+
+          css('a[target]').each do |node|
+            node.remove_attribute('target') unless node['href'].start_with?('http')
+          end
+        end
+
+        css('a[id]:empty').each do |node|
+          (node.next_element || node.parent.next_element)['id'] = node['id']
+        end
+
+        css('h1 > code').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('pre > code').each do |node|
+          node.parent['data-language'] = node['class'][/lang-(\w+)/, 1] if node['class']
+          node.parent.content = node.parent.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 29 - 0
lib/docs/filters/redux/entries.rb

@@ -0,0 +1,29 @@
+module Docs
+  class Redux
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('.page-inner h1, .page-inner h2').content
+        name.sub! %r{\(.*\)}, '()'
+        name
+      end
+
+      def get_type
+        path = slug.split('/')
+
+        if path.length > 1
+          path[0].titleize.sub('Api', 'API')
+        else
+          'Miscellaneous'
+        end
+      end
+
+      def additional_entries
+        css('#store-methods + ul > li > a').map do |node|
+          id = node['href'].remove('#')
+          name = "#{self.name}##{id}()"
+          [name, id]
+        end
+      end
+    end
+  end
+end

+ 24 - 0
lib/docs/scrapers/redux.rb

@@ -0,0 +1,24 @@
+module Docs
+  class Redux < UrlScraper
+    self.type = 'redux'
+    self.release = '3.5.2'
+    self.base_url = 'http://redux.js.org/docs/'
+    self.links = {
+      home: 'http://redux.js.org/',
+      code: 'https://github.com/reactjs/redux/'
+    }
+
+    html_filters.push 'redux/entries', 'redux/clean_html'
+
+    options[:skip] = %w(Feedback.html)
+
+    options[:attribution] = <<-HTML
+      &copy; 2015&ndash;2016 Dan Abramov<br>
+      Licensed under the MIT License.
+    HTML
+
+    stub '' do
+      request_one('http://redux.js.org/index.html').body
+    end
+  end
+end

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


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


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

@@ -0,0 +1 @@
+http://redux.js.org/gitbook/images/favicon.ico