瀏覽代碼

Update Moment.js documentation (2.29.4)

Simon Legner 3 年之前
父節點
當前提交
dbe0b56365
共有 3 個文件被更改,包括 22 次插入17 次删除
  1. 1 1
      lib/docs/filters/moment/clean_html.rb
  2. 19 14
      lib/docs/filters/moment/entries.rb
  3. 2 2
      lib/docs/scrapers/moment.rb

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

@@ -4,7 +4,7 @@ module Docs
       def call
         # Set id attributes on headings
         css('a.docs-section-target', 'a.docs-method-target').each do |node|
-          node.next_element['id'] = node['name'].remove(/\A\//).remove(/\/\z/).gsub('/', '-')
+          node.next_element['id'] = node['id']
           node.remove
         end
 

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

@@ -6,10 +6,11 @@ module Docs
         Plugins
         Guides:\ External\ Resources)
       IGNORE_IDS = %w(
-        i18n-loading-into-nodejs
-        i18n-loading-into-browser
-        i18n-adding-locale
-        i18n-getting-locale)
+        /i18n/loading-into-nodejs/
+        /i18n/loading-into-browser/
+        /i18n/adding-locale/
+        /i18n/getting-locale/
+      )
 
       def get_name
         if subpath == '/guides/'
@@ -39,26 +40,30 @@ module Docs
           next if IGNORE_TYPES.include?(type)
           next if IGNORE_IDS.include?(node['id'])
 
-          if node['id'] == 'utilities-invalid' # bug fix
-            name = 'moment.invalid()'
-          elsif node['id'] == 'customization-now'
-            name = 'moment.now'
-          elsif %w(Display Durations Get\ +\ Set i18n Manipulate Query Utilities).include?(type) ||
-                %w(parsing-is-valid parsing-parse-zone parsing-unix-timestamp parsing-utc parsing-creation-data customization-relative-time-threshold customization-relative-time-rounding
-                  customization-calendar-format).include?(node['id'])
+          if %w(Display Durations Get\ +\ Set i18n Manipulate Query Utilities).include?(type) ||
+             %w(/parsing/is-valid/
+                /parsing/parse-zone/
+                /parsing/unix-timestamp/
+                /parsing/utc/
+                /parsing/creation-data/
+                /customization/relative-time-threshold/
+                /customization/relative-time-rounding/
+                /customization/calendar-format/
+                /customization/now/
+              ).include?(node['id'])
             name = node.next_element.content[/moment(?:\(.*?\))?\.(?:duration\(\)\.)?\w+/]
             name.sub! %r{\(.*?\)\.}, '#'
             name << '()'
           elsif type == 'Customize'
             name = node.next_element.content[/moment.locale\(.+?\{\s+(\w+)/, 1]
+            name = node.content.strip unless name
             name.prepend 'Locale#'
           else
             name = node.content.strip
-            name.remove! %r{\s[\d\.]+[\s\+]*\z} # remove version number
-            name.remove! %r{\s\(.+\)\z}  # remove parenthesis
             name.prepend 'Parse: ' if type == 'Parse'
           end
-
+          name.remove! %r{\s[\d\.]+[\s\+]*\z} # remove version number
+          name.remove! %r{\s\(.+\)\z}  # remove parenthesis
           entries << [name, node['id'], type]
         end
 

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

@@ -3,8 +3,8 @@ module Docs
     self.name = 'Moment.js'
     self.slug = 'moment'
     self.type = 'moment'
-    self.release = '2.22.1'
-    self.base_url = 'http://momentjs.com'
+    self.release = '2.29.4'
+    self.base_url = 'https://momentjs.com'
     self.root_path = '/docs/'
     self.initial_paths = %w(/guides/)
     self.links = {