History

Update Moment.js documentation (2.16.0)

Thibaut Courouble committed 10 years ago

Commit d29d25c1 parent 5d364583 files · +24 −9Browse files

Unified · Split

3 files
  1. lib/docs/filters/moment/clean_html.rb +1 −7
  2. lib/docs/filters/moment/entries.rb +19 −0
  3. lib/docs/scrapers/moment.rb +4 −2
lib/docs/filters/moment/clean_html.rb+1−7
@@ -12,13 +12,7 @@ module Docs · 11 unmodified lines
12 node.before(node.children).remove12 node.before(node.children).remove
13 end13 end
14 14
15 # Remove introduction15 css('.docs-method-edit', 'hr').remove
16 doc.child.remove while doc.child['id'] != 'parsing'
17
18 # Remove plugin list
19 doc.children.last.remove while doc.children.last['id'] != 'plugins'
20
21 css('.docs-method-edit', '#plugins', 'hr').remove
22 16
23 css('pre').each do |node|17 css('pre').each do |node|
24 if node.content =~ /\A</18 if node.content =~ /\A</
lib/docs/filters/moment/entries.rb+19−0
@@ -1,12 +1,28 @@
1module Docs1module Docs
2 class Moment2 class Moment
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4 IGNORE_TYPES = %w(
5 Where\ to\ use\ it
6 Plugins
7 Guides:\ External\ Resources)
4 IGNORE_IDS = %w(8 IGNORE_IDS = %w(
5 i18n-loading-into-nodejs9 i18n-loading-into-nodejs
6 i18n-loading-into-browser10 i18n-loading-into-browser
7 i18n-adding-locale11 i18n-adding-locale
8 i18n-getting-locale)12 i18n-getting-locale)
9 13
14 def get_name
15 if subpath == '/guides/'
16 'Guides'
17 end
18 end
19
20 def get_type
21 if subpath == '/guides/'
22 'Guides'
23 end
24 end
25
10 def additional_entries26 def additional_entries
11 entries = []27 entries = []
12 type = nil28 type = nil
@@ -14,10 +30,13 @@ module Docs · 1 unmodified line
14 css('[id]').each do |node|30 css('[id]').each do |node|
15 if node.name == 'h2'31 if node.name == 'h2'
16 type = node.content32 type = node.content
33 type.remove! ' Guide'
34 type.prepend 'Guides: ' if subpath == '/guides/'
17 next35 next
18 end36 end
19 37
20 next unless node.name == 'h3'38 next unless node.name == 'h3'
39 next if IGNORE_TYPES.include?(type)
21 next if IGNORE_IDS.include?(node['id'])40 next if IGNORE_IDS.include?(node['id'])
22 41
23 if node['id'] == 'utilities-invalid' # bug fix42 if node['id'] == 'utilities-invalid' # bug fix
lib/docs/scrapers/moment.rb+4−2
@@ -3,8 +3,10 @@ module Docs · 2 unmodified lines
3 self.name = 'Moment.js'3 self.name = 'Moment.js'
4 self.slug = 'moment'4 self.slug = 'moment'
5 self.type = 'moment'5 self.type = 'moment'
6 self.release = '2.15.2'6 self.release = '2.16.0'
7 self.base_url = 'http://momentjs.com/docs/'7 self.base_url = 'http://momentjs.com'
8 self.root_path = '/docs/'
9 self.initial_paths = %w(/guides/)
8 10
9 html_filters.push 'moment/clean_html', 'moment/entries', 'title'11 html_filters.push 'moment/clean_html', 'moment/entries', 'title'
10 12