浏览代码

Update Moment.js documentation (2.16.0)

Thibaut Courouble 9 年之前
父节点
当前提交
d29d25ce6b
共有 3 个文件被更改,包括 24 次插入9 次删除
  1. 1 7
      lib/docs/filters/moment/clean_html.rb
  2. 19 0
      lib/docs/filters/moment/entries.rb
  3. 4 2
      lib/docs/scrapers/moment.rb

+ 1 - 7
lib/docs/filters/moment/clean_html.rb

@@ -12,13 +12,7 @@ module Docs
           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('.docs-method-edit', '#plugins', 'hr').remove
+        css('.docs-method-edit', 'hr').remove
 
         css('pre').each do |node|
           if node.content =~ /\A</

+ 19 - 0
lib/docs/filters/moment/entries.rb

@@ -1,12 +1,28 @@
 module Docs
   class Moment
     class EntriesFilter < Docs::EntriesFilter
+      IGNORE_TYPES = %w(
+        Where\ to\ use\ it
+        Plugins
+        Guides:\ External\ Resources)
       IGNORE_IDS = %w(
         i18n-loading-into-nodejs
         i18n-loading-into-browser
         i18n-adding-locale
         i18n-getting-locale)
 
+      def get_name
+        if subpath == '/guides/'
+          'Guides'
+        end
+      end
+
+      def get_type
+        if subpath == '/guides/'
+          'Guides'
+        end
+      end
+
       def additional_entries
         entries = []
         type = nil
@@ -14,10 +30,13 @@ module Docs
         css('[id]').each do |node|
           if node.name == 'h2'
             type = node.content
+            type.remove! ' Guide'
+            type.prepend 'Guides: ' if subpath == '/guides/'
             next
           end
 
           next unless node.name == 'h3'
+          next if IGNORE_TYPES.include?(type)
           next if IGNORE_IDS.include?(node['id'])
 
           if node['id'] == 'utilities-invalid' # bug fix

+ 4 - 2
lib/docs/scrapers/moment.rb

@@ -3,8 +3,10 @@ module Docs
     self.name = 'Moment.js'
     self.slug = 'moment'
     self.type = 'moment'
-    self.release = '2.15.2'
-    self.base_url = 'http://momentjs.com/docs/'
+    self.release = '2.16.0'
+    self.base_url = 'http://momentjs.com'
+    self.root_path = '/docs/'
+    self.initial_paths = %w(/guides/)
 
     html_filters.push 'moment/clean_html', 'moment/entries', 'title'