فهرست منبع

Add Vuex reference

Nicolas Ettlin 7 سال پیش
والد
کامیت
57232ce130

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -680,6 +680,11 @@ credits = [
     '2013-2018 Evan You, Vue.js contributors',
     'MIT',
     'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE'
+  ], [
+    'Vuex',
+    '2015-2018 Evan You, Vue.js contributors',
+    'MIT',
+    'https://raw.githubusercontent.com/vuejs/vuex/master/LICENSE'
   ], [
     'Vulkan',
     '2014-2017 Khronos Group Inc.<br>Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.',

+ 14 - 0
lib/docs/filters/vuex/clean_html.rb

@@ -0,0 +1,14 @@
+module Docs
+  class Vuex
+    class CleanHtmlFilter < Filter
+      def call
+        @doc = at_css('.content')
+
+        # Remove unneeded elements
+        css('.header-anchor').remove
+
+        doc
+      end
+    end
+  end
+end

+ 68 - 0
lib/docs/filters/vuex/entries.rb

@@ -0,0 +1,68 @@
+module Docs
+  class Vuex
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content
+
+        name.remove! '# '
+
+        # Add index on guides
+        unless subpath.start_with?('api')
+          sidebarLink = at_css('.sidebar-link.active')
+          allLinks = css('.sidebar-link:not([href="/"]):not([href="../index"])')
+
+          index = allLinks.index(sidebarLink)
+
+          name.prepend "#{index + 1}. " if index
+        end
+
+        name
+      end
+
+      def get_type
+        'Guide'
+      end
+
+      def include_default_entry?
+        name != 'API Reference'
+      end
+
+      def additional_entries
+        return [] unless subpath.start_with?('api') 
+
+        entries = [
+          ['Component Binding Helpers', 'component-binding-helpers', 'API Reference'],
+          ['Store', 'vuex-store', 'API Reference'],
+        ]
+
+        css('h3').each do |node|
+          entryName = node.content.strip
+
+          # Get the previous h2 title
+          title = node
+          title = title.previous_element until title.name == 'h2'
+          title = title.content.strip
+          title.remove! '# '
+
+          entryName.remove! '# '
+
+          unless entryName.start_with?('router.')
+            if title == "Vuex.Store Constructor Options"
+              entryName = "StoreOptions.#{entryName}"
+            elsif title == "Vuex.Store Instance Properties"
+              entryName = "Vuex.Store.#{entryName}"
+            elsif title == "Vuex.Store Instance Methods"
+              entryName = "Vuex.Store.#{entryName}()"
+            elsif title == "Component Binding Helpers"
+              entryName = "#{entryName}()"
+            end
+          end
+
+          entries << [entryName, node['id'], 'API Reference']
+        end
+
+        entries
+      end
+    end
+  end
+end

+ 26 - 0
lib/docs/scrapers/vuex.rb

@@ -0,0 +1,26 @@
+module Docs
+  class Vuex < UrlScraper
+    self.name = 'Vuex'
+    self.type = 'simple'
+
+    self.links = {
+      home: 'https://vuex.vuejs.org',
+      code: 'https://github.com/vuejs/vuex'
+    }
+
+    html_filters.push 'vuex/entries', 'vuex/clean_html'
+
+    self.release = '3.0.1'
+    self.base_url = 'https://vuex.vuejs.org/'
+
+    options[:skip_patterns] = [
+      # Other languages
+      /^(zh|ja|ru|kr|fr|ptbr)\//,
+    ]
+
+    options[:attribution] = <<-HTML
+      &copy; 2015&ndash;2018 Evan You, Vue.js contributors<br>
+      Licensed under the MIT License.
+    HTML
+  end
+end

BIN
public/icons/docs/vuex/16.png


BIN
public/icons/docs/vuex/16@2x.png


+ 1 - 0
public/icons/docs/vuex/SOURCE

@@ -0,0 +1 @@
+http://vuejs.org/