From cd41d39abca98f074c4019816c4f7aa657de0f2e Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sun, 9 Oct 2022 21:04:34 +0200 Subject: [PATCH] Add Vitest documentation (0.24.0) --- assets/javascripts/news.json | 2 +- .../templates/pages/about_tmpl.coffee | 5 ++++ lib/docs/filters/vite/clean_html.rb | 1 + lib/docs/filters/vitest/entries.rb | 28 ++++++++++++++++++ lib/docs/scrapers/vitest.rb | 28 ++++++++++++++++++ public/icons/docs/vitest/16.png | Bin 0 -> 893 bytes public/icons/docs/vitest/16@2x.png | Bin 0 -> 1668 bytes public/icons/docs/vitest/SOURCE | 1 + 8 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 lib/docs/filters/vitest/entries.rb create mode 100644 lib/docs/scrapers/vitest.rb create mode 100644 public/icons/docs/vitest/16.png create mode 100644 public/icons/docs/vitest/16@2x.png create mode 100644 public/icons/docs/vitest/SOURCE 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 0000000000000000000000000000000000000000..fd44a6bb81f1521ca4d996e25d1b4df9fcf0c804 GIT binary patch literal 893 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!63?wyl`GbL!WQl7;NpOBzNqJ&XDnogBxn5>o zc5!lIL8@MUQTpt6Hc~)EEa{HEjtmSN`?>!lvI6-E$sR$z3=CCj3=9n|3=F@3LJcn% z7)lKo7+xhXFj&oCU=S~uvn$XBD8XLh>Fdh=jEhsqOslL!Yb8*Kv%n*=80ZdZ5M~VA zC2)g*fiWz=C&U#f`RBOy|NRa{Go@M=$Shl}STtL@Zl3htKwX!2eOmFa zFstWXM#3U{{(fp^WEEyA`uD(?QI%gY&zw;+VcE~vyCLk}m5i>x7jwK_D#m6NdRc9m zFk8@xTq~crcU)6H=QG7G7v`P*DN*EG&rB9p&fBt}C}&Lac6TXU&mQv#$hqL@;us=v zIXQuW*-aq9fvKm*Xj6|yjb$aPTZ-M{MU#x2#D$d?cV#us+Qk;pFmvY2*1+J^3ml@| z!~3W9_B!4_Fk$ZD6FU|xIB;aj4`+>26M`!2L fr`?^N%{LfUA5*^fws2=UC}cfd{an^LB{Ts5>>q1; literal 0 HcmV?d00001 diff --git a/public/icons/docs/vitest/16@2x.png b/public/icons/docs/vitest/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..051339ca942bd2dbe81b840d45f9b19fb3f661c0 GIT binary patch literal 1668 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSM@i<$9TU z*~Q6;1*v-ZMd`EO*+>Buv7|ftIx;Y9?C1WI$Oa@a2CEqi4B`cIb_Lo1CD=C6}Jp92))EbxddW?&GI24Tj) zT>>{47?@TD_=LCuCI1}P{(D0A&vBi<$94an(EfK!@BeAtKgYEH9@qJQQsXyJ_L$b6 z6WV`{Y5hK<{`;i%@8ep(k82jqk}8@hRWMVsaF*o%#SFiXX%^3xE}1P;G+R1rj#%Y% znd0ffg|nmzW=Z`$qV@Nbbnt(`7TdCF-Zi z-O(wBPtbU<%R=-63TABQ5l69+PGMC7d&XvlaDw#h=rf{}Y#v);0$Pk5q zfkUK9qLo2{7Z}2DlYs#XMKeJm4?%EQGzLO3P!|rxFw-P}kpedjB3L+G5@H~bTQ~#C z28zIyf!M$V07idK=s*=iM5cq?2A2hU8LAlQ5~w)XRWLQcbOIAcFbd{KgKPo1f0oq$ z|Nn0@8_zD@-l;}!j%sBky=OYu_tA9H!8_RfXobi%^{Y|de=Wk=3tsHLiEjp$lzAEmxmeV_}o;jL~w+gnPbVsSb-K|$2O$jHd>@zj3*goBG4rcTr~)SM}}+{T(c z*()o`Dv!0NM{?%(&6^6f9;BQ(xwqb4pM5%$Uf!`kO~1c$S4tE{1%%Z6|MyqO&EUY4 z=c#A(SWn&8*IvJ3&8oB~&eNZZC#+eym!GlpD{oKJ3^5b4yX}ov(%ckR?AWlOqhp1H zhoiT4%)Yg;a{`@$yreiJTCA;hryOa}lK8y)Ay-wEq~uc7rN4ivdl+~4%rU9#(g|RF zd?oX8`k6Vbljhs9Yv}9Rmf!osTEwHoEv_47;~Eyn_`>+8s`qrpr_kl{`{gm)};o+XJS?+yKUuHWVIu&#I*NuI z+jjBZuQxl}`5Qm+rELf(yCPy)|4=cYb@FDR#ocNi{~oDkvWL6ayx7SZzmF-T@M`Q~ zW}W)CySkQZ7x`3HI*0z?aDLKSdobC+GNN#_BN3`#NBL5cG2$fIs3PMbn{RD)irKOiQ bDzPveo6eYU@re9ZP;T&a^>bP0l+XkKQ$@Q3 literal 0 HcmV?d00001 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