Add Moment.js documentation

This commit is contained in:
Thibaut 2014-02-16 16:37:04 -05:00
parent 68809b0ddd
commit 032457e527
13 changed files with 116 additions and 1 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 39 KiB

View file

@ -143,6 +143,11 @@ credits = [
'2009-2013 The Dojo Foundation',
'MIT',
'https://raw.github.com/lodash/lodash/master/LICENSE.txt'
], [
'Moment.js',
'2011-2014 Tim Wood, Iskren Chernev, Moment.js contributors',
'MIT',
'https://raw.github.com/moment/moment/master/LICENSE'
], [
'Node.js',
'Joyent, Inc. and other Node contributors<br>Node.js is a trademark of Joyent, Inc.',

View file

@ -24,7 +24,10 @@ newsItem = (date, news) ->
result
app.news = [
[ 1392163200000, # February 12, 2013
[ 1392508800000, # February 16, 2013
""" New <a href="/moment/">Moment.js</a> documentation """,
], [
1392163200000, # February 12, 2013
""" The root/category pages are now included in the search index (e.g. <a href="/#q=CSS">CSS</a>) """,
], [
1390694400000, # January 26, 2013

View file

@ -0,0 +1,6 @@
#= require views/pages/base
class app.views.MomentPage extends app.views.BasePage
afterRender: ->
@highlightCode @findAll('pre'), 'javascript'
return

View file

@ -37,6 +37,7 @@
'pages/less',
'pages/lodash',
'pages/mdn',
'pages/moment',
'pages/node',
'pages/php',
'pages/postgres',

View file

@ -47,3 +47,4 @@
._icon-postgresql:before { background-position: -3rem -6rem; }
._icon-d3:before { background-position: -4rem -6rem; }
._icon-knockout:before { background-position: 0 -7rem; }
._icon-moment:before { background-position: -1rem -7rem; }

View file

@ -0,0 +1,7 @@
._moment {
> h2 { @extend %block-heading; }
> h3 { @extend %block-label, %label-blue; }
> h3 > span { float: right;}
h4 { font-size: 1em; }
code { @extend %label; }
}

View file

@ -0,0 +1,26 @@
module Docs
class Moment
class CleanHtmlFilter < Filter
def call
# Set id attributes on headings
css('a.target').each do |node|
node.next_element['id'] = node['name'].sub(/\A\//, '').sub(/\/\z/, '').gsub('/', '-')
end
css('> article', '.prose', 'h2 > a', 'h3 > a', 'pre > code').each do |node|
node.before(node.children).remove
end
# Remove introduction
doc.child.remove while doc.child['id'] != 'parsing'
# Remove plugin list
doc.children.last.remove while doc.children.last['id'] != 'plugins'
css('.hash', '#plugins').remove
doc
end
end
end
end

View file

@ -0,0 +1,46 @@
module Docs
class Moment
class EntriesFilter < Docs::EntriesFilter
IGNORE_IDS = %w(
i18n-loading-into-nodejs
i18n-loading-into-browser
i18n-adding-language
i18n-getting-language)
def additional_entries
entries = []
type = nil
css('[id]').each do |node|
if node.name == 'h2'
type = node.content
next
end
next if IGNORE_IDS.include?(node['id'])
if node['id'] == 'utilities-invalid' # bug fix
name = 'moment.invalid()'
elsif %w(Display Durations Get\ +\ Set i18n Manipulate Query Utilities).include?(type) ||
%w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc).include?(node['id'])
name = node.next_element.content[/moment(?:\(.*?\))?\.(?:duration\(\)\.)?\w+/]
name.sub! %r{\(.*?\)\.}, '#'
name << '()'
elsif type == 'Customize'
name = node.next_element.content[/moment.lang\(.+?\{\s+(\w+)/, 1]
name.prepend 'Language#'
else
name = node.content.strip
name.sub! %r{\s[\d\.]+\z}, '' # remove version number
name.sub! %r{\s\(.+\)\z}, '' # remove parenthesis
name.prepend 'Parse: ' if type == 'Parse'
end
entries << [name, node['id'], type]
end
entries
end
end
end
end

View file

@ -0,0 +1,20 @@
module Docs
class Moment < UrlScraper
self.name = 'Moment.js'
self.slug = 'moment'
self.type = 'moment'
self.version = '2.5.1'
self.base_url = 'http://momentjs.com/docs/'
html_filters.push 'moment/clean_html', 'moment/entries', 'title'
options[:title] = 'Moment.js'
options[:container] = '.docs'
options[:skip_links] = true
options[:attribution] = <<-HTML
&copy; 2011&ndash;2014 Tim Wood, Iskren Chernev, Moment.js contributors<br>
Licensed under the MIT License.
HTML
end
end

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B