Skip to content

Commit 43b664a

Browse files
authored
Merge pull request #2079 from freeCodeCamp/svelte
Update Svelte documentation (4.2.1)
2 parents 17909c7 + 0ac5412 commit 43b664a

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

lib/docs/filters/svelte/clean_html.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@ module Docs
22
class Svelte
33
class CleanHtmlFilter < Filter
44
def call
5-
@doc = at_css('main > .content')
6-
at_css('h1').content = 'Svelte'
5+
@doc = at_css('main .page.content')
6+
at_css('h1').content = 'Svelte' if root_page?
7+
css('pre').each do |node|
8+
node.content = node.css('.line').map(&:content).join("\n")
9+
node['data-language'] = 'javascript'
10+
end
711
doc
812
end
913
end

lib/docs/filters/svelte/entries.rb

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@ module Docs
22
class Svelte
33
class EntriesFilter < Docs::EntriesFilter
44
def get_type
5-
'Svelte'
5+
at_css('ul.sidebar > li:has(.active) > span.section').content
66
end
77

88
def additional_entries
9-
type = 'Svelte'
109
subtype = nil
10+
css('aside').remove
11+
css('.category').remove
12+
css('.controls').remove
13+
css('.edit').remove
14+
css('.permalink').remove
1115
css('h2, h3, h4').each_with_object [] do |node, entries|
1216
if node.name == 'h2'
13-
type = node.content.strip
1417
subtype = nil
1518
elsif node.name == 'h3'
1619
subtype = node.content.strip
@@ -19,7 +22,8 @@ def additional_entries
1922
next if type == 'Before we begin'
2023
name = node.content.strip
2124
name.concat " (#{subtype})" if subtype && node.name == 'h4'
22-
entries << [name, node['id'], subtype || type]
25+
next if name.starts_with?('Example')
26+
entries << [name, node['id'], get_type]
2327
end
2428
end
2529
end

lib/docs/scrapers/svelte.rb

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,27 @@ class Svelte < UrlScraper
88
code: 'https://github.com/sveltejs/svelte'
99
}
1010

11+
self.root_path = 'introduction'
1112
options[:root_title] = 'Svelte'
1213

14+
# https://github.com/sveltejs/svelte/blob/master/LICENSE.md
1315
options[:attribution] = <<-HTML
14-
&copy; 2016–2022 Rich Harris and contributors<br>
16+
&copy; 2016–2023 Rich Harris and contributors<br>
1517
Licensed under the MIT License.
1618
HTML
1719

1820
options[:skip] = %w(team.html plugins/)
1921

20-
self.release = '3.55.0'
21-
self.base_url = 'https://svelte.dev/docs'
22+
self.base_url = 'https://svelte.dev/docs/'
2223
html_filters.push 'svelte/entries', 'svelte/clean_html'
24+
25+
version do
26+
self.release = '4.2.1'
27+
end
28+
29+
version '3' do
30+
self.release = '3.55.0'
31+
end
2332

2433
def get_latest_version(opts)
2534
get_npm_version('svelte', opts)

0 commit comments

Comments
 (0)