瀏覽代碼

Add Vitest documentation (0.24.0)

Simon Legner 3 年之前
父節點
當前提交
cd41d39abc

+ 1 - 1
assets/javascripts/news.json

@@ -1,7 +1,7 @@
 [
   [
     "2022-10-09",
-    "New documentation: <a href=\"/fastapi/\">FastAPI</a>"
+    "New documentations: <a href=\"/fastapi/\">FastAPI</a>, <a href=\"/vitest/\">Vitest</a>"
   ],
   [
     "2022-10-02",

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

@@ -936,6 +936,11 @@ credits = [
     '2019–present, Yuxi (Evan) You and Vite contributors',
     'MIT',
     'https://github.com/vitejs/vite/blob/main/LICENSE'
+  ], [
+    'Vitest',
+    '2021-Present Anthony Fu<br>2021-Present Matias Capeletto<br>',
+    'MIT',
+    'https://github.com/vitest-dev/vitest/blob/main/LICENSE'
   ], [
     'Vue Router',
     '2013-present Evan You',

+ 1 - 0
lib/docs/filters/vite/clean_html.rb

@@ -2,6 +2,7 @@ module Docs
   class Vite
     class CleanHtmlFilter < Filter
       def call
+        return "<h1>Vitest</h1><p>A Vite-native unit test framework. It's fast!</p>" if root_page? && current_url.host == 'vitest.dev'
         return '<h1>Vite</h1>' if root_page?
         @doc = at_css('main h1').parent
 

+ 28 - 0
lib/docs/filters/vitest/entries.rb

@@ -0,0 +1,28 @@
+module Docs
+  class Vitest
+    class EntriesFilter < Docs::EntriesFilter
+      def get_name
+        name = at_css('h1').content
+        name.sub! %r{\s*#\s*}, ''
+        name
+      end
+
+      def get_type
+        name = at_css('h1').content
+        name.sub! %r{\s*#\s*}, ''
+        name
+      end
+
+      def additional_entries
+        return [] if root_page?
+        css('h2[id], h3[id]').each_with_object [] do |node, entries|
+          text = node.content.strip
+          text.sub! %r{\s*#\s*}, ''
+          next if text == 'Example'
+          text.prepend "#{name}: " unless slug.starts_with?('api') || slug.starts_with?('config')
+          entries << [text, node['id']]
+        end
+      end
+    end
+  end
+end

+ 28 - 0
lib/docs/scrapers/vitest.rb

@@ -0,0 +1,28 @@
+module Docs
+  class Vitest < UrlScraper
+    self.name = 'Vitest'
+    self.slug = 'vitest'
+    self.type = 'simple'
+    self.links = {
+      home: 'https://vitest.dev/',
+      code: 'https://github.com/vitest-dev/vitest'
+    }
+
+    options[:root_title] = 'Vitest'
+
+    options[:attribution] = <<-HTML
+      &copy; 2021-Present Anthony Fu<br>
+      &copy; 2021-Present Matias Capeletto<br>
+      Licensed under the MIT License.
+    HTML
+
+    self.release = '0.24.0'
+    self.base_url = 'https://vitest.dev/'
+    self.initial_paths = %w(guide/)
+    html_filters.push 'vitest/entries', 'vite/clean_html'
+
+    def get_latest_version(opts)
+      get_npm_version('vitest', opts)
+    end
+  end
+end

二進制
public/icons/docs/vitest/16.png


二進制
public/icons/docs/vitest/16@2x.png


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

@@ -0,0 +1 @@
+https://vitest.dev/logo.svg