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
1212 node.before(node.children).remove
1313 end
1414
15− # Remove introduction
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
15+ css('.docs-method-edit', 'hr').remove
2216
2317 css('pre').each do |node|
2418 if node.content =~ /\A</
lib/docs/filters/moment/entries.rb+19−0
@@ -1,12 +1,28 @@
11 module Docs
22 class Moment
33 class EntriesFilter < Docs::EntriesFilter
4+ IGNORE_TYPES = %w(
5+ Where\ to\ use\ it
6+ Plugins
7+ Guides:\ External\ Resources)
48 IGNORE_IDS = %w(
59 i18n-loading-into-nodejs
610 i18n-loading-into-browser
711 i18n-adding-locale
812 i18n-getting-locale)
913
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+
1026 def additional_entries
1127 entries = []
1228 type = nil
@@ -14,10 +30,13 @@ module Docs · 1 unmodified line
1430 css('[id]').each do |node|
1531 if node.name == 'h2'
1632 type = node.content
33+ type.remove! ' Guide'
34+ type.prepend 'Guides: ' if subpath == '/guides/'
1735 next
1836 end
1937
2038 next unless node.name == 'h3'
39+ next if IGNORE_TYPES.include?(type)
2140 next if IGNORE_IDS.include?(node['id'])
2241
2342 if node['id'] == 'utilities-invalid' # bug fix
lib/docs/scrapers/moment.rb+4−2
@@ -3,8 +3,10 @@ module Docs · 2 unmodified lines
33 self.name = 'Moment.js'
44 self.slug = 'moment'
55 self.type = 'moment'
6− self.release = '2.15.2'
7− self.base_url = 'http://momentjs.com/docs/'
6+ self.release = '2.16.0'
7+ self.base_url = 'http://momentjs.com'
8+ self.root_path = '/docs/'
9+ self.initial_paths = %w(/guides/)
810
911 html_filters.push 'moment/clean_html', 'moment/entries', 'title'
1012