Showing the changes to lib/docs (3 of 8 files). Show all
Unified · Split
| @@ -2,6 +2,7 @@ module Docs · 1 unmodified line | ||
| 2 | 2 | class Vite |
| 3 | 3 | class CleanHtmlFilter < Filter |
| 4 | 4 | def call |
| 5 | + return "<h1>Vitest</h1><p>A Vite-native unit test framework. It's fast!</p>" if root_page? && current_url.host == 'vitest.dev' | |
| 5 | 6 | return '<h1>Vite</h1>' if root_page? |
| 6 | 7 | @doc = at_css('main h1').parent |
| 7 | 8 | |
| @@ -0,0 +1,28 @@ | ||
| 1 | +module Docs | |
| 2 | + class Vitest | |
| 3 | + class EntriesFilter < Docs::EntriesFilter | |
| 4 | + def get_name | |
| 5 | + name = at_css('h1').content | |
| 6 | + name.sub! %r{\s*#\s*}, '' | |
| 7 | + name | |
| 8 | + end | |
| 9 | + | |
| 10 | + def get_type | |
| 11 | + name = at_css('h1').content | |
| 12 | + name.sub! %r{\s*#\s*}, '' | |
| 13 | + name | |
| 14 | + end | |
| 15 | + | |
| 16 | + def additional_entries | |
| 17 | + return [] if root_page? | |
| 18 | + css('h2[id], h3[id]').each_with_object [] do |node, entries| | |
| 19 | + text = node.content.strip | |
| 20 | + text.sub! %r{\s*#\s*}, '' | |
| 21 | + next if text == 'Example' | |
| 22 | + text.prepend "#{name}: " unless slug.starts_with?('api') || slug.starts_with?('config') | |
| 23 | + entries << [text, node['id']] | |
| 24 | + end | |
| 25 | + end | |
| 26 | + end | |
| 27 | + end | |
| 28 | +end | |
| @@ -0,0 +1,28 @@ | ||
| 1 | +module Docs | |
| 2 | + class Vitest < UrlScraper | |
| 3 | + self.name = 'Vitest' | |
| 4 | + self.slug = 'vitest' | |
| 5 | + self.type = 'simple' | |
| 6 | + self.links = { | |
| 7 | + home: 'https://vitest.dev/', | |
| 8 | + code: 'https://github.com/vitest-dev/vitest' | |
| 9 | + } | |
| 10 | + | |
| 11 | + options[:root_title] = 'Vitest' | |
| 12 | + | |
| 13 | + options[:attribution] = <<-HTML | |
| 14 | + © 2021-Present Anthony Fu<br> | |
| 15 | + © 2021-Present Matias Capeletto<br> | |
| 16 | + Licensed under the MIT License. | |
| 17 | + HTML | |
| 18 | + | |
| 19 | + self.release = '0.24.0' | |
| 20 | + self.base_url = 'https://vitest.dev/' | |
| 21 | + self.initial_paths = %w(guide/) | |
| 22 | + html_filters.push 'vitest/entries', 'vite/clean_html' | |
| 23 | + | |
| 24 | + def get_latest_version(opts) | |
| 25 | + get_npm_version('vitest', opts) | |
| 26 | + end | |
| 27 | + end | |
| 28 | +end | |