1
0
Thibaut Courouble 9 жил өмнө
parent
commit
a0cfe45f21

BIN
assets/images/docs.png


BIN
assets/images/docs@2x.png


+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2016-11-20",
-    "New documentation: <a href=\"/immutable/\">Immutable.js</a>"
+    "New documentations: <a href=\"/yarn/\">Yarn</a> and <a href=\"/immutable/\">Immutable.js</a>"
   ], [
     "2016-10-10",
     "New documentations: <a href=\"/scikit_learn/\">scikit-learn</a> and <a href=\"/statsmodels/\">Statsmodels</a>"

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

@@ -574,6 +574,11 @@ credits = [
     '2012-2016 Tobias Koppers',
     'MIT',
     'https://raw.githubusercontent.com/webpack/webpack/master/LICENSE'
+  ], [
+    'Yarn',
+    '2016 Yarn Contributors',
+    'BSD',
+    'https://raw.githubusercontent.com/yarnpkg/yarn/master/LICENSE'
   ], [
     'Yii',
     '2008-2016 by Yii Software LLC',

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

@@ -60,5 +60,6 @@ app.views.UnderscorePage =
 app.views.VagrantPage =
 app.views.VuePage =
 app.views.WebpackPage =
+app.views.YarnPage =
 app.views.YiiPage =
 app.views.SimplePage

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

@@ -72,6 +72,7 @@
 ._icon-angularjs:before     { background-position: -9rem -1rem; }
 ._icon-coffeescript:before  { background-position: 0 -2rem; @extend %darkIconFix !optional; }
 ._icon-ember:before         { background-position: -1rem -2rem; }
+._icon-yarn:before          { background-position: -2rem -2rem; }
 ._icon-immutable:before     { background-position: -3rem -2rem; @extend %darkIconFix !optional; }
 ._icon-jqueryui:before      { background-position: -4rem -2rem; }
 ._icon-jquerymobile:before  { background-position: -5rem -2rem; }

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

@@ -36,6 +36,7 @@
 ._redux,
 ._sinon,
 ._typescript,
-._webpack {
+._webpack,
+._yarn {
   @extend %simple;
 }

+ 56 - 0
lib/docs/filters/yarn/clean_html.rb

@@ -0,0 +1,56 @@
+module Docs
+  class Yarn
+    class CleanHtmlFilter < Filter
+      def call
+        root_page? ? root : other
+        doc
+      end
+
+      def root
+        @doc = at_css('.hero + .container')
+
+        at_css('.row').remove
+        css('> .container', 'hr').remove
+
+        css('.row', '.col-lg-4', '.card-block').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('a.card').each do |node|
+          node.at_css('.float-right').replace %(<br><a href="#{node['href']}">Read more</a>)
+          node.before(node.children).remove
+        end
+      end
+
+      def other
+        @doc = at_css('.guide')
+
+        css('a.toc', '.nav-tabs', '#select-platform', '.guide-controls + .list-group', '.guide-controls').remove
+
+        css('.guide-content', '.tabs', '.tab-content').each do |node|
+          node.before(node.children).remove
+        end
+
+        unless at_css('h2')
+          css('h3', 'h4', 'h5').each do |node|
+            node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
+          end
+        end
+
+        unless at_css('h3')
+          css('h4', 'h5').each do |node|
+            node.name = node.name.sub(/\d/) { |i| i.to_i - 1 }
+          end
+        end
+
+        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')
+      end
+    end
+  end
+end

+ 21 - 0
lib/docs/filters/yarn/entries.rb

@@ -0,0 +1,21 @@
+module Docs
+  class Yarn
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content
+
+        unless type == 'CLI'
+          name.prepend "#{css('.guide-nav a').to_a.index(at_css('.guide-nav a.active')) + 1}. "
+        end
+
+        name
+      end
+
+      def get_type
+        type = at_css('.guide-nav a').content.strip
+        type.remove! ' Introduction'
+        type
+      end
+    end
+  end
+end

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

@@ -0,0 +1,24 @@
+module Docs
+  class Yarn < UrlScraper
+    self.type = 'yarn'
+    self.release = '0.17.6'
+    self.base_url = 'https://yarnpkg.com/en/docs/'
+    self.links = {
+      home: 'https://yarnpkg.com/',
+      code: 'https://github.com/yarnpkg/yarn'
+    }
+
+    html_filters.push 'yarn/entries', 'yarn/clean_html', 'title'
+
+    options[:root_title] = 'Yarn'
+    options[:trailing_slash] = false
+
+    options[:skip] = %w(nightly)
+    options[:skip_patterns] = [/\Aorg\//]
+
+    options[:attribution] = <<-HTML
+      &copy; 2016 Yarn Contributors<br>
+      Licensed under the BSD License.
+    HTML
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://raw.githubusercontent.com/yarnpkg/website/master/favicon.ico