diff --git a/lib/docs/filters/svelte/clean_html.rb b/lib/docs/filters/svelte/clean_html.rb
index 693825f7..cdc929ea 100644
--- a/lib/docs/filters/svelte/clean_html.rb
+++ b/lib/docs/filters/svelte/clean_html.rb
@@ -2,11 +2,23 @@ module Docs
class Svelte
class CleanHtmlFilter < Filter
def call
- @doc = at_css('main .page.content')
+ @doc = at_css('main .page.content #docs-content')
+
+ # Remove title header
+ at_css('> header > div.breadcrumbs').remove()
+ # Remove extra input toggle
+ at_css('> aside.on-this-page input').remove()
+ # Remove "edit this page" link
+ at_css('> p.edit').remove()
+ # Remove footer navigation
+ at_css('> div.controls').remove()
+
at_css('h1').content = 'Svelte' if root_page?
css('pre').each do |node|
+ # Remove hover popup
+ node.css('.twoslash-popup-container').remove()
node.content = node.css('.line').map(&:content).join("\n")
- node['data-language'] = 'javascript'
+ node['data-language'] = 'typescript'
end
doc
end
diff --git a/lib/docs/filters/svelte/entries.rb b/lib/docs/filters/svelte/entries.rb
index dcd66cc2..c349898a 100644
--- a/lib/docs/filters/svelte/entries.rb
+++ b/lib/docs/filters/svelte/entries.rb
@@ -2,29 +2,14 @@ module Docs
class Svelte
class EntriesFilter < Docs::EntriesFilter
def get_type
- at_css('ul.sidebar > li:has(.active) > span.section').content
+ page = at_css("main nav ul.sidebar li ul li a[href$='#{result[:path]}']")
+ category = page.ancestors('li')[1]
+ return category.css('h3').inner_text
end
- def additional_entries
- subtype = nil
- css('aside').remove
- css('.category').remove
- css('.controls').remove
- css('.edit').remove
- css('.permalink').remove
- css('h2, h3, h4').each_with_object [] do |node, entries|
- if node.name == 'h2'
- subtype = nil
- elsif node.name == 'h3'
- subtype = node.content.strip
- subtype = nil unless subtype[/Component directives|Element directives/]
- end
- next if type == 'Before we begin'
- name = node.content.strip
- name.concat " (#{subtype})" if subtype && node.name == 'h4'
- next if name.starts_with?('Example')
- entries << [name, node['id'], get_type]
- end
+ def get_name
+ page = at_css("main nav ul.sidebar li ul li a[href$='#{result[:path]}']")
+ return page.inner_text
end
end
end
diff --git a/lib/docs/scrapers/svelte.rb b/lib/docs/scrapers/svelte.rb
index c5900a0b..aac87389 100644
--- a/lib/docs/scrapers/svelte.rb
+++ b/lib/docs/scrapers/svelte.rb
@@ -3,26 +3,28 @@ module Docs
self.name = 'Svelte'
self.slug = 'svelte'
self.type = 'simple'
+ self.root_path = '/'
self.links = {
home: 'https://svelte.dev/',
code: 'https://github.com/sveltejs/svelte'
}
- self.root_path = 'introduction'
options[:root_title] = 'Svelte'
# https://github.com/sveltejs/svelte/blob/master/LICENSE.md
options[:attribution] = <<-HTML
- © 2016–2023 Rich Harris and contributors
+ © 2016–2024 Rich Harris and contributors
Licensed under the MIT License.
HTML
- options[:skip] = %w(team.html plugins/)
-
- self.base_url = 'https://svelte.dev/docs/'
+ self.base_url = 'https://svelte.dev/docs/svelte/'
html_filters.push 'svelte/entries', 'svelte/clean_html'
-
+
version do
+ self.release = '5.2.3'
+ end
+
+ version '4' do
self.release = '4.2.1'
end