瀏覽代碼

Update and version Sinon.JS documentation

Thibaut Courouble 8 年之前
父節點
當前提交
7e5c3fc43a

二進制
assets/images/docs.png


二進制
assets/images/docs@2x.png


+ 2 - 2
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -531,9 +531,9 @@ credits = [
     'https://raw.githubusercontent.com/scikit-learn/scikit-learn/master/COPYING'
   ], [
     'Sinon',
-    '2010-2016 Christian Johansen',
+    '2010-2017 Christian Johansen',
     'BSD',
-    'https://raw.githubusercontent.com/cjohansen/Sinon.JS/master/LICENSE'
+    'https://raw.githubusercontent.com/sinonjs/sinon/master/LICENSE'
   ], [
     'Socket.io',
     '2014-2015 Automattic',

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

@@ -81,6 +81,7 @@
         'pages/rfc',
         'pages/rubydoc',
         'pages/rust',
+        'pages/sinon',
         'pages/socketio',
         'pages/sphinx',
         'pages/sphinx_simple',

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

@@ -81,6 +81,7 @@
         'pages/rfc',
         'pages/rubydoc',
         'pages/rust',
+        'pages/sinon',
         'pages/socketio',
         'pages/sphinx',
         'pages/sphinx_simple',

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

@@ -93,7 +93,7 @@
 ._icon-haskell:before       { background-position: -6rem -4rem; }
 ._icon-requirejs:before     { background-position: -7rem -4rem; }
 ._icon-chai:before          { background-position: -8rem -4rem; }
-._icon-sinon:before         { background-position: -9rem -4rem; @extend %darkIconFix !optional; }
+._icon-sinon:before         { background-position: -9rem -4rem; }
 ._icon-cordova:before       { background-position: 0 -5rem; }
 ._icon-markdown:before      { background-position: -1rem -5rem; @extend %darkIconFix !optional; }
 ._icon-django:before        { background-position: -2rem -5rem; }

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

@@ -35,7 +35,6 @@
 ._mocha,
 ._mongoose,
 ._redux,
-._sinon,
 ._typescript,
 ._yarn {
   @extend %simple;

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

@@ -0,0 +1,5 @@
+._sinon {
+  @extend %simple;
+
+  h4 { @extend %block-label;}
+}

+ 10 - 4
lib/docs/filters/sinon/clean_html.rb

@@ -2,15 +2,21 @@ module Docs
   class Sinon
     class CleanHtmlFilter < Filter
       def call
-        css('> p:first-child', 'a.api', 'ul.nav').remove
+        if root_page?
+          at_css('h1').content = 'Sinon.JS'
+        else
+          css('h1').each do |node|
+            node.content = node.content.remove(' - Sinon.JS')
+          end
+        end
 
-        css('.section', 'h2 code', 'h3 code').each do |node|
+        css('.post', '.post-header', '.post-content', 'pre code').each do |node|
           node.before(node.children).remove
         end
 
-        # Remove code highlighting
+        css('h1 + h1').remove
+
         css('pre').each do |node|
-          node.content = node.content
           node['data-language'] = 'javascript'
         end
 

+ 16 - 35
lib/docs/filters/sinon/entries.rb

@@ -1,46 +1,27 @@
 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
+      def get_name
+        at_css('h1').content.strip
+      end
 
-            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
+      def get_type
+        name
+      end
 
-              next if name =~ /\s/
-              next if entries.any? { |entry| entry[0].casecmp(name) == 0 }
+      def additional_entries
+        css('h4 > code').each_with_object [] do |node, entries|
+          name = node.content.strip
+          name.sub! %r{\s*\(.*\);?}, '()'
+          name.sub! %r{\A(\w+\.\w+)\s+\=.*}, '\1'
+          name.remove! %r{\A.+?\=\s+}
+          name.remove! %r{\A\w+?\s}
+          name.remove! %r{;\z}
 
-              id = name.parameterize
-              code.parent['id'] = id
+          next if entries.any? { |entry| entry[0].casecmp(name) == 0 }
 
-              entries << [name, id, type]
-            end
-          end
+          entries << [name, node.parent['id']]
         end
-
-        entries
       end
     end
   end

+ 16 - 8
lib/docs/scrapers/sinon.rb

@@ -1,23 +1,31 @@
 module Docs
   class Sinon < UrlScraper
-    self.name = 'Sinon'
+    self.name = 'Sinon.JS'
+    self.slug = 'sinon'
     self.type = 'sinon'
-    self.release = '1.17.5'
-    self.base_url = 'http://sinonjs.org/docs/'
     self.links = {
       home: 'http://sinonjs.org/',
-      code: 'https://github.com/cjohansen/Sinon.JS'
+      code: 'https://github.com/sinonjs/sinon'
     }
 
-    html_filters.push 'sinon/clean_html', 'sinon/entries', 'title'
+    html_filters.push 'sinon/clean_html', 'sinon/entries'
 
     options[:title] = 'Sinon.JS'
-    options[:container] = '.docs'
-    options[:skip_links] = true
+    options[:container] = '.content .container'
 
     options[:attribution] = <<-HTML
-      &copy; 2010&ndash;2016 Christian Johansen<br>
+      &copy; 2010&ndash;2017 Christian Johansen<br>
       Licensed under the BSD License.
     HTML
+
+    version '2' do
+      self.release = '2.1.0'
+      self.base_url = "http://sinonjs.org/releases/v#{release}/"
+    end
+
+    version '1' do
+      self.release = '1.17.7'
+      self.base_url = "http://sinonjs.org/releases/v#{release}/"
+    end
   end
 end

二進制
public/icons/docs/sinon/16.png


二進制
public/icons/docs/sinon/16@2x.png


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

@@ -1 +1 @@
-https://github.com/Kapeli/Dash-X-Platform-Resources/blob/master/docset_icons/sinon%402x.png
+https://github.com/sinonjs/sinon/blob/master/docs/assets/images/logo.png