Skip to content

Commit

Permalink
Merge pull request #2363 from ruiiiijiiiiang/feature/update-svelte-ve…
Browse files Browse the repository at this point in the history
…rsion

Updated svelte version
  • Loading branch information
simon04 authored Nov 19, 2024
2 parents e18ddad + 9102197 commit 642dea3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 29 deletions.
16 changes: 14 additions & 2 deletions lib/docs/filters/svelte/clean_html.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 6 additions & 21 deletions lib/docs/filters/svelte/entries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions lib/docs/scrapers/svelte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,28 @@ class Svelte < UrlScraper
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
&copy; 2016–2023 Rich Harris and contributors<br>
&copy; 2016–2024 Rich Harris and contributors<br>
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

Expand Down

0 comments on commit 642dea3

Please sign in to comment.