mirror of https://github.com/freeCodeCamp/devdocs
parent
68809b0ddd
commit
032457e527
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
@ -0,0 +1,6 @@
|
||||
#= require views/pages/base
|
||||
|
||||
class app.views.MomentPage extends app.views.BasePage
|
||||
afterRender: ->
|
||||
@highlightCode @findAll('pre'), 'javascript'
|
||||
return
|
@ -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; }
|
||||
}
|
@ -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
|
@ -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
|
@ -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
|
||||
© 2011–2014 Tim Wood, Iskren Chernev, Moment.js contributors<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 230 B |
After Width: | Height: | Size: 469 B |
Loading…
Reference in new issue