History

Add Knockout.js documentation

Thibaut committed 12 years ago

Commit ece6ff81 parent 6b0390d14 files · +121 −-1Browse 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 +2 −2
  5. assets/javascripts/views/pages/knockout.coffee +8 −0
  6. assets/stylesheets/application.css.scss +1 −0
  7. assets/stylesheets/global/_icons.scss +2 −1
  8. assets/stylesheets/pages/_knockout.scss +6 −0
  9. lib/docs/filters/knockout/clean_html.rb +30 −0
  10. lib/docs/filters/knockout/entries.rb +38 −0
  11. lib/docs/scrapers/knockout.rb +32 −0
  12. public/icons/docs/knockout/16.png +0 −0
  13. public/icons/docs/knockout/16@2x.png +0 −0
  14. public/icons/docs/knockout/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
@@ -128,6 +128,11 @@ credits = [ · 127 unmodified lines
128128 '2014 jQuery Foundation',
129129 'MIT',
130130 'https://raw.github.com/jquery/api.jqueryui.com/master/LICENSE-MIT.txt'
131+ ], [
132+ 'Knockout.js',
133+ 'Steven Sanderson, the Knockout.js team, and other contributors',
134+ 'MIT',
135+ 'https://raw.github.com/knockout/knockout/master/LICENSE'
131136 ], [
132137 'Less',
133138 '2009-2014 Alexis Sellier & The Core Less Team',
assets/javascripts/templates/pages/news_tmpl.coffee+2−2
@@ -24,8 +24,8 @@ newsItem = (date, news) -> · 23 unmodified lines
2424 result
2525
2626 app.news = [
27− [ 1390089600000, # January 19, 2013
28− """ New <a href="/d3/">D3.js</a> documentation """,
27+ [ 1390089600001, # January 19, 2013
28+ """ New <a href="/d3/">D3.js</a> and <a href="/knockout/">Knockout.js</a> documentations """,
2929 ], [
3030 1390003200000, # January 18, 2013
3131 """ DevDocs is now available as a <a href="https://marketplace.firefox.com/app/devdocs/">Firefox web app</a> (currently requires Aurora). """,
assets/javascripts/views/pages/knockout.coffee+8−0
@@ -0,0 +1,8 @@
1+#= require views/pages/base
2+
3+class app.views.KnockoutPage extends app.views.BasePage
4+ afterRender: ->
5+ for el in @findAll('pre')
6+ language = if el.innerHTML.indexOf('data-bind="') > 0 then 'markup' else 'javascript'
7+ @highlightCode el, language
8+ return
assets/stylesheets/application.css.scss+1−0
@@ -32,6 +32,7 @@ · 31 unmodified lines
3232 'pages/d3',
3333 'pages/ember',
3434 'pages/jquery',
35+ 'pages/knockout',
3536 'pages/git',
3637 'pages/less',
3738 'pages/lodash',
assets/stylesheets/global/_icons.scss+2−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
44 width: 1rem;
55 height: 1rem;
66 background-image: image-url('icons.png');
7− background-size: 5rem 7rem;
7+ background-size: 5rem 8rem;
88 }
99
1010 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -46,3 +46,4 @@ · 35 unmodified lines
4646 ._icon-redis:before { background-position: -2rem -6rem; }
4747 ._icon-postgresql:before { background-position: -3rem -6rem; }
4848 ._icon-d3:before { background-position: -4rem -6rem; }
49+._icon-knockout:before { background-position: 0 -7rem; }
assets/stylesheets/pages/_knockout.scss+6−0
@@ -0,0 +1,6 @@
1+._knockout {
2+ > h2 { @extend %block-heading; }
3+ > h3 { @extend %block-label, %label-blue; }
4+ p > code { @extend %label; }
5+ .liveExample { @extend %note; }
6+}
lib/docs/filters/knockout/clean_html.rb+30−0
@@ -0,0 +1,30 @@
1+module Docs
2+ class Knockout
3+ class CleanHtmlFilter < Filter
4+ def call
5+ root_page? ? root : other
6+
7+ css('pre > code').each do |node|
8+ node.before(node.children).remove
9+ end
10+
11+ doc
12+ end
13+
14+ def root
15+ @doc = at_css '.content'
16+ at_css('h1').content = 'Knockout.js'
17+ end
18+
19+ def other
20+ css('h1 ~ h1').each do |node|
21+ node.name = 'h2'
22+ end
23+
24+ css('.liveExample').each do |node|
25+ node.content = 'Live examples are not available on DevDocs, sorry.'
26+ end
27+ end
28+ end
29+ end
30+end
lib/docs/filters/knockout/entries.rb+38−0
@@ -0,0 +1,38 @@
1+module Docs
2+ class Knockout
3+ class EntriesFilter < Docs::EntriesFilter
4+ NAME_BY_SLUG = {
5+ 'custom-bindings' => 'Custom bindings',
6+ 'custom-bindings-controlling-descendant-bindings' => 'Descendant bindings',
7+ 'custom-bindings-for-virtual-elements' => 'Virtual elements',
8+ 'binding-preprocessing' => 'Binding preprocessing',
9+ 'json-data' => 'JSON data',
10+ 'extenders' => 'Extending observables',
11+ 'unobtrusive-event-handling' => 'Event handling',
12+ 'fn' => 'Custom functions' }
13+
14+ def get_name
15+ return NAME_BY_SLUG[slug] if NAME_BY_SLUG.has_key?(slug)
16+ name = at_css('h1').content.strip
17+ name.sub! 'The ', ''
18+ name.sub! %r{"(.+?)"}, '\1'
19+ name.gsub!(/ [A-Z]/) { |str| str.downcase! }
20+ name
21+ end
22+
23+ def get_type
24+ if name =~ /observable/i || slug =~ /extender/
25+ 'Observables'
26+ elsif slug.include?('binding') && !name.end_with?('binding')
27+ 'Binding'
28+ elsif slug.include? 'binding'
29+ 'Bindings'
30+ elsif slug.include? 'plugin'
31+ 'Plugins'
32+ else
33+ 'Miscellaneous'
34+ end
35+ end
36+ end
37+ end
38+end
lib/docs/scrapers/knockout.rb+32−0
@@ -0,0 +1,32 @@
1+module Docs
2+ class Knockout < UrlScraper
3+ self.name = 'Knockout.js'
4+ self.slug = 'knockout'
5+ self.type = 'knockout'
6+ self.version = '3.0.0'
7+ self.base_url = 'http://knockoutjs.com/documentation/'
8+ self.root_path = 'introduction.html'
9+
10+ html_filters.push 'knockout/clean_html', 'knockout/entries'
11+
12+ options[:follow_links] = ->(filter) { filter.root_page? }
13+ options[:container] = ->(filter) { filter.root_page? ? '#wrapper' : '.content' }
14+
15+ options[:only] = %w(
16+ json-data.html
17+ extenders.html
18+ throttle-extender.html
19+ unobtrusive-event-handling.html
20+ fn.html)
21+
22+ options[:only_patterns] = [
23+ /observable/i,
24+ /binding/,
25+ /plugin/]
26+
27+ options[:attribution] = <<-HTML
28+ &copy; Steven Sanderson, the Knockout.js team, and other contributors<br>
29+ Licensed under the MIT License.
30+ HTML
31+ end
32+end
public/icons/docs/knockout/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/knockout/SOURCE+1−0
@@ -0,0 +1 @@
1+http://learn.knockoutjs.com/