فهرست منبع

Add Sinon documentation

Thibaut 11 سال پیش
والد
کامیت
63715a31f9

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


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

@@ -235,6 +235,11 @@ credits = [
     '2006-2014 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
     'MIT',
     'https://raw.github.com/nex3/sass/master/MIT-LICENSE'
+  ], [
+    'Sinon',
+    '2010-2014 Christian Johansen',
+    'BSD',
+    'https://raw.githubusercontent.com/cjohansen/Sinon.JS/master/LICENSE'
   ], [
     'Underscore.js',
     '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',

+ 1 - 1
assets/javascripts/templates/pages/news_tmpl.coffee

@@ -25,7 +25,7 @@ newsItem = (date, news) ->
 
 app.news = [
   [ 1404172800000, # July 1, 2014
-    """ New <a href="/chai/">Chai</a> documentation """,
+    """ New <a href="/chai/">Chai</a> and <a href="/sinon/">Sinon</a> documentations """,
   ], [
     1402790400000, # June 15, 2014
     """ New <a href="/requirejs/">RequireJS</a> documentation """,

+ 4 - 0
assets/javascripts/views/pages/sinon.coffee

@@ -0,0 +1,4 @@
+#= require views/pages/base
+#= require views/pages/underscore
+
+app.views.SinonPage = app.views.UnderscorePage

+ 1 - 0
assets/stylesheets/application.css.scss

@@ -54,6 +54,7 @@
         'pages/redis',
         'pages/requirejs',
         'pages/rfc',
+        'pages/sinon',
         'pages/sphinx',
         'pages/underscore',
         'pages/yard',

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

@@ -60,3 +60,4 @@
 ._icon-haskell:before       { background-position: -1rem -9rem; }
 ._icon-requirejs:before     { background-position: -2rem -9rem; }
 ._icon-chai:before          { background-position: -3rem -9rem; }
+._icon-sinon:before         { background-position: -4rem -9rem; }

+ 9 - 0
assets/stylesheets/pages/_sinon.scss

@@ -0,0 +1,9 @@
+._sinon {
+  padding-left: 1rem;
+
+  > h1, > h2, > h3 { margin-left: -1rem; }
+  > h2 { @extend %block-heading; }
+  > h3 { @extend %block-label, %label-blue; }
+
+  dt > code { @extend %label; }
+}

+ 20 - 0
lib/docs/filters/sinon/clean_html.rb

@@ -0,0 +1,20 @@
+module Docs
+  class Sinon
+    class CleanHtmlFilter < Filter
+      def call
+        css('> p:first-child', 'a.api', 'ul.nav').remove
+
+        css('.section', 'h2 code', 'h3 code').each do |node|
+          node.before(node.children).remove
+        end
+
+        # Remove code highlighting
+        css('pre').each do |node|
+          node.content = node.content
+        end
+
+        doc
+      end
+    end
+  end
+end

+ 47 - 0
lib/docs/filters/sinon/entries.rb

@@ -0,0 +1,47 @@
+module Docs
+  class Sinon
+    class EntriesFilter < Docs::EntriesFilter
+      def additional_entries
+        entries = []
+        type = config = nil
+
+        css('*').each do |node|
+          if node.name == 'h2'
+            config = false
+            type = node.content.strip
+            type.remove! 'Test '
+            type.remove! 'Sinon.JS '
+            type = type[0].upcase + type.from(1)
+
+            id = type.parameterize
+            node['id'] = id
+
+            entries << [type, id, 'Sections']
+          elsif node.name == 'h3' && node.content.include?('sinon.config')
+            config = true
+          elsif node.name == 'dl'
+            node.css('dt > code').each do |code|
+              name = code.content.strip
+              name.sub! %r{\(.*\);?}, '()'
+              name.sub! %r{\Aserver.(\w+)\s=.*\z}, 'server.\1'
+              name.remove! '`'
+              name.remove! %r{\A.+?\=\s+}
+              name.remove! %r{\A\w+?\s}
+              name.prepend 'sinon.config.' if config
+
+              next if name =~ /\s/
+              next if entries.any? { |entry| entry[0].casecmp(name) == 0 }
+
+              id = name.parameterize
+              code.parent['id'] = id
+
+              entries << [name, id, type]
+            end
+          end
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 19 - 0
lib/docs/scrapers/sinon.rb

@@ -0,0 +1,19 @@
+module Docs
+  class Sinon < UrlScraper
+    self.name = 'Sinon'
+    self.type = 'sinon'
+    self.version = '1.10.2'
+    self.base_url = 'http://sinonjs.org/docs/'
+
+    html_filters.push 'sinon/clean_html', 'sinon/entries', 'title'
+
+    options[:title] = 'Sinon.JS'
+    options[:container] = '.docs'
+    options[:skip_links] = true
+
+    options[:attribution] = <<-HTML
+      &copy; 2010&ndash;2014 Christian Johansen<br>
+      Licensed under the BSD License.
+    HTML
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://github.com/Kapeli/Dash-X-Platform-Resources/blob/master/docset_icons/sinon%402x.png