History

Add Sinon documentation

Thibaut committed 12 years ago

Commit 63715a31 parent 46f6db414 files · +104 −-3Browse files

Unified · Split

14 files
  1. assets/images/icons.png +0 −0
  2. assets/images/icons@2x.png +0 −0
  3. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  4. assets/javascripts/templates/pages/news_tmpl.coffee +1 −1
  5. assets/javascripts/views/pages/sinon.coffee +4 −0
  6. assets/stylesheets/application.css.scss +1 −0
  7. assets/stylesheets/global/_icons.scss +1 −0
  8. assets/stylesheets/pages/_sinon.scss +9 −0
  9. lib/docs/filters/sinon/clean_html.rb +20 −0
  10. lib/docs/filters/sinon/entries.rb +47 −0
  11. lib/docs/scrapers/sinon.rb +19 −0
  12. public/icons/docs/sinon/16.png +0 −0
  13. public/icons/docs/sinon/16@2x.png +0 −0
  14. public/icons/docs/sinon/SOURCE +1 −0
assets/images/icons.png+0−0

Binary file not shown.

assets/images/icons@2x.png+0−0

Binary file not shown.

assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -235,6 +235,11 @@ credits = [ · 234 unmodified lines
235 '2006-2014 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',235 '2006-2014 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein',
236 'MIT',236 'MIT',
237 'https://raw.github.com/nex3/sass/master/MIT-LICENSE'237 'https://raw.github.com/nex3/sass/master/MIT-LICENSE'
238 ], [
239 'Sinon',
240 '2010-2014 Christian Johansen',
241 'BSD',
242 'https://raw.githubusercontent.com/cjohansen/Sinon.JS/master/LICENSE'
238 ], [243 ], [
239 'Underscore.js',244 'Underscore.js',
240 '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',245 '2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors',
assets/javascripts/templates/pages/news_tmpl.coffee+1−1
@@ -25,7 +25,7 @@ newsItem = (date, news) -> · 24 unmodified lines
25 25
26app.news = [26app.news = [
27 [ 1404172800000, # July 1, 201427 [ 1404172800000, # July 1, 2014
28 """ New <a href="/chai/">Chai</a> documentation """,28 """ New <a href="/chai/">Chai</a> and <a href="/sinon/">Sinon</a> documentations """,
29 ], [29 ], [
30 1402790400000, # June 15, 201430 1402790400000, # June 15, 2014
31 """ New <a href="/requirejs/">RequireJS</a> documentation """,31 """ New <a href="/requirejs/">RequireJS</a> documentation """,
assets/javascripts/views/pages/sinon.coffee+4−0
@@ -0,0 +1,4 @@
1#= require views/pages/base
2#= require views/pages/underscore
3
4app.views.SinonPage = app.views.UnderscorePage
assets/stylesheets/application.css.scss+1−0
@@ -54,6 +54,7 @@ · 53 unmodified lines
54 'pages/redis',54 'pages/redis',
55 'pages/requirejs',55 'pages/requirejs',
56 'pages/rfc',56 'pages/rfc',
57 'pages/sinon',
57 'pages/sphinx',58 'pages/sphinx',
58 'pages/underscore',59 'pages/underscore',
59 'pages/yard',60 'pages/yard',
assets/stylesheets/global/_icons.scss+1−0
@@ -60,3 +60,4 @@ · 59 unmodified lines
60._icon-haskell:before { background-position: -1rem -9rem; }60._icon-haskell:before { background-position: -1rem -9rem; }
61._icon-requirejs:before { background-position: -2rem -9rem; }61._icon-requirejs:before { background-position: -2rem -9rem; }
62._icon-chai:before { background-position: -3rem -9rem; }62._icon-chai:before { background-position: -3rem -9rem; }
63._icon-sinon:before { background-position: -4rem -9rem; }
assets/stylesheets/pages/_sinon.scss+9−0
@@ -0,0 +1,9 @@
1._sinon {
2 padding-left: 1rem;
3
4 > h1, > h2, > h3 { margin-left: -1rem; }
5 > h2 { @extend %block-heading; }
6 > h3 { @extend %block-label, %label-blue; }
7
8 dt > code { @extend %label; }
9}
lib/docs/filters/sinon/clean_html.rb+20−0
@@ -0,0 +1,20 @@
1module Docs
2 class Sinon
3 class CleanHtmlFilter < Filter
4 def call
5 css('> p:first-child', 'a.api', 'ul.nav').remove
6
7 css('.section', 'h2 code', 'h3 code').each do |node|
8 node.before(node.children).remove
9 end
10
11 # Remove code highlighting
12 css('pre').each do |node|
13 node.content = node.content
14 end
15
16 doc
17 end
18 end
19 end
20end
lib/docs/filters/sinon/entries.rb+47−0
@@ -0,0 +1,47 @@
1module Docs
2 class Sinon
3 class EntriesFilter < Docs::EntriesFilter
4 def additional_entries
5 entries = []
6 type = config = nil
7
8 css('*').each do |node|
9 if node.name == 'h2'
10 config = false
11 type = node.content.strip
12 type.remove! 'Test '
13 type.remove! 'Sinon.JS '
14 type = type[0].upcase + type.from(1)
15
16 id = type.parameterize
17 node['id'] = id
18
19 entries << [type, id, 'Sections']
20 elsif node.name == 'h3' && node.content.include?('sinon.config')
21 config = true
22 elsif node.name == 'dl'
23 node.css('dt > code').each do |code|
24 name = code.content.strip
25 name.sub! %r{\(.*\);?}, '()'
26 name.sub! %r{\Aserver.(\w+)\s=.*\z}, 'server.\1'
27 name.remove! '`'
28 name.remove! %r{\A.+?\=\s+}
29 name.remove! %r{\A\w+?\s}
30 name.prepend 'sinon.config.' if config
31
32 next if name =~ /\s/
33 next if entries.any? { |entry| entry[0].casecmp(name) == 0 }
34
35 id = name.parameterize
36 code.parent['id'] = id
37
38 entries << [name, id, type]
39 end
40 end
41 end
42
43 entries
44 end
45 end
46 end
47end
lib/docs/scrapers/sinon.rb+19−0
@@ -0,0 +1,19 @@
1module Docs
2 class Sinon < UrlScraper
3 self.name = 'Sinon'
4 self.type = 'sinon'
5 self.version = '1.10.2'
6 self.base_url = 'http://sinonjs.org/docs/'
7
8 html_filters.push 'sinon/clean_html', 'sinon/entries', 'title'
9
10 options[:title] = 'Sinon.JS'
11 options[:container] = '.docs'
12 options[:skip_links] = true
13
14 options[:attribution] = <<-HTML
15 &copy; 2010&ndash;2014 Christian Johansen<br>
16 Licensed under the BSD License.
17 HTML
18 end
19end
public/icons/docs/sinon/16.png+0−0

Binary file not shown.

public/icons/docs/sinon/16@2x.png+0−0

Binary file not shown.

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