Add Knockout.js documentation

pull/47/head
Thibaut 11 years ago
parent 6b0390d7c7
commit ece6ff80fd

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 39 KiB

@ -128,6 +128,11 @@ credits = [
'2014 jQuery Foundation',
'MIT',
'https://raw.github.com/jquery/api.jqueryui.com/master/LICENSE-MIT.txt'
], [
'Knockout.js',
'Steven Sanderson, the Knockout.js team, and other contributors',
'MIT',
'https://raw.github.com/knockout/knockout/master/LICENSE'
], [
'Less',
'2009-2014 Alexis Sellier & The Core Less Team',

@ -24,8 +24,8 @@ newsItem = (date, news) ->
result
app.news = [
[ 1390089600000, # January 19, 2013
""" New <a href="/d3/">D3.js</a> documentation """,
[ 1390089600001, # January 19, 2013
""" New <a href="/d3/">D3.js</a> and <a href="/knockout/">Knockout.js</a> documentations """,
], [
1390003200000, # January 18, 2013
""" DevDocs is now available as a <a href="https://marketplace.firefox.com/app/devdocs/">Firefox web app</a> (currently requires Aurora). """,

@ -0,0 +1,8 @@
#= require views/pages/base
class app.views.KnockoutPage extends app.views.BasePage
afterRender: ->
for el in @findAll('pre')
language = if el.innerHTML.indexOf('data-bind="') > 0 then 'markup' else 'javascript'
@highlightCode el, language
return

@ -32,6 +32,7 @@
'pages/d3',
'pages/ember',
'pages/jquery',
'pages/knockout',
'pages/git',
'pages/less',
'pages/lodash',

@ -4,7 +4,7 @@
width: 1rem;
height: 1rem;
background-image: image-url('icons.png');
background-size: 5rem 7rem;
background-size: 5rem 8rem;
}
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@ -46,3 +46,4 @@
._icon-redis:before { background-position: -2rem -6rem; }
._icon-postgresql:before { background-position: -3rem -6rem; }
._icon-d3:before { background-position: -4rem -6rem; }
._icon-knockout:before { background-position: 0 -7rem; }

@ -0,0 +1,6 @@
._knockout {
> h2 { @extend %block-heading; }
> h3 { @extend %block-label, %label-blue; }
p > code { @extend %label; }
.liveExample { @extend %note; }
}

@ -0,0 +1,30 @@
module Docs
class Knockout
class CleanHtmlFilter < Filter
def call
root_page? ? root : other
css('pre > code').each do |node|
node.before(node.children).remove
end
doc
end
def root
@doc = at_css '.content'
at_css('h1').content = 'Knockout.js'
end
def other
css('h1 ~ h1').each do |node|
node.name = 'h2'
end
css('.liveExample').each do |node|
node.content = 'Live examples are not available on DevDocs, sorry.'
end
end
end
end
end

@ -0,0 +1,38 @@
module Docs
class Knockout
class EntriesFilter < Docs::EntriesFilter
NAME_BY_SLUG = {
'custom-bindings' => 'Custom bindings',
'custom-bindings-controlling-descendant-bindings' => 'Descendant bindings',
'custom-bindings-for-virtual-elements' => 'Virtual elements',
'binding-preprocessing' => 'Binding preprocessing',
'json-data' => 'JSON data',
'extenders' => 'Extending observables',
'unobtrusive-event-handling' => 'Event handling',
'fn' => 'Custom functions' }
def get_name
return NAME_BY_SLUG[slug] if NAME_BY_SLUG.has_key?(slug)
name = at_css('h1').content.strip
name.sub! 'The ', ''
name.sub! %r{"(.+?)"}, '\1'
name.gsub!(/ [A-Z]/) { |str| str.downcase! }
name
end
def get_type
if name =~ /observable/i || slug =~ /extender/
'Observables'
elsif slug.include?('binding') && !name.end_with?('binding')
'Binding'
elsif slug.include? 'binding'
'Bindings'
elsif slug.include? 'plugin'
'Plugins'
else
'Miscellaneous'
end
end
end
end
end

@ -0,0 +1,32 @@
module Docs
class Knockout < UrlScraper
self.name = 'Knockout.js'
self.slug = 'knockout'
self.type = 'knockout'
self.version = '3.0.0'
self.base_url = 'http://knockoutjs.com/documentation/'
self.root_path = 'introduction.html'
html_filters.push 'knockout/clean_html', 'knockout/entries'
options[:follow_links] = ->(filter) { filter.root_page? }
options[:container] = ->(filter) { filter.root_page? ? '#wrapper' : '.content' }
options[:only] = %w(
json-data.html
extenders.html
throttle-extender.html
unobtrusive-event-handling.html
fn.html)
options[:only_patterns] = [
/observable/i,
/binding/,
/plugin/]
options[:attribution] = <<-HTML
&copy; Steven Sanderson, the Knockout.js team, and other contributors<br>
Licensed under the MIT License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 902 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

@ -0,0 +1 @@
http://learn.knockoutjs.com/
Loading…
Cancel
Save