diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index cb2b1f34..b951eabd 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,7 +1,7 @@ [ [ "2022-10-09", - "New documentation: FastAPI" + "New documentations: FastAPI, Vitest" ], [ "2022-10-02", diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 2a20f48a..087e7e3d 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/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
2021-Present Matias Capeletto
', + 'MIT', + 'https://github.com/vitest-dev/vitest/blob/main/LICENSE' ], [ 'Vue Router', '2013-present Evan You', diff --git a/lib/docs/filters/vite/clean_html.rb b/lib/docs/filters/vite/clean_html.rb index 18cf1d55..76917658 100644 --- a/lib/docs/filters/vite/clean_html.rb +++ b/lib/docs/filters/vite/clean_html.rb @@ -2,6 +2,7 @@ module Docs class Vite class CleanHtmlFilter < Filter def call + return "

Vitest

A Vite-native unit test framework. It's fast!

" if root_page? && current_url.host == 'vitest.dev' return '

Vite

' if root_page? @doc = at_css('main h1').parent diff --git a/lib/docs/filters/vitest/entries.rb b/lib/docs/filters/vitest/entries.rb new file mode 100644 index 00000000..03527ef6 --- /dev/null +++ b/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 diff --git a/lib/docs/scrapers/vitest.rb b/lib/docs/scrapers/vitest.rb new file mode 100644 index 00000000..8b5a27a3 --- /dev/null +++ b/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 + © 2021-Present Anthony Fu
+ © 2021-Present Matias Capeletto
+ 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 diff --git a/public/icons/docs/vitest/16.png b/public/icons/docs/vitest/16.png new file mode 100644 index 00000000..fd44a6bb Binary files /dev/null and b/public/icons/docs/vitest/16.png differ diff --git a/public/icons/docs/vitest/16@2x.png b/public/icons/docs/vitest/16@2x.png new file mode 100644 index 00000000..051339ca Binary files /dev/null and b/public/icons/docs/vitest/16@2x.png differ diff --git a/public/icons/docs/vitest/SOURCE b/public/icons/docs/vitest/SOURCE new file mode 100644 index 00000000..911a2163 --- /dev/null +++ b/public/icons/docs/vitest/SOURCE @@ -0,0 +1 @@ +https://vitest.dev/logo.svg