diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 73d07cc1..e596a931 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,4 +1,8 @@ [ + [ + "2022-10-02", + "New documentation: Svelte" + ], [ "2022-09-21", "Added HTTP/3 to HTTP" diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 161cd8c7..cda606e4 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -871,6 +871,11 @@ credits = [ '2009-2012 Statsmodels Developers
© 2006-2008 Scipy Developers
© 2006 Jonathan E. Taylor', 'BSD', 'https://raw.githubusercontent.com/statsmodels/statsmodels/master/LICENSE.txt' + ], [ + 'Svelte', + '2016–2022 Rich Harris and contributors', + 'MIT', + 'https://raw.githubusercontent.com/sveltejs/svelte/master/LICENSE.md' ], [ 'Symfony', '2004-2017 Fabien Potencier', diff --git a/lib/docs/filters/svelte/clean_html.rb b/lib/docs/filters/svelte/clean_html.rb new file mode 100644 index 00000000..579b27b7 --- /dev/null +++ b/lib/docs/filters/svelte/clean_html.rb @@ -0,0 +1,11 @@ +module Docs + class Svelte + class CleanHtmlFilter < Filter + def call + @doc = at_css('main > .content') + at_css('h1').content = 'Svelte' + doc + end + end + end +end diff --git a/lib/docs/filters/svelte/entries.rb b/lib/docs/filters/svelte/entries.rb new file mode 100644 index 00000000..ab7236ff --- /dev/null +++ b/lib/docs/filters/svelte/entries.rb @@ -0,0 +1,27 @@ +module Docs + class Svelte + class EntriesFilter < Docs::EntriesFilter + def get_type + 'Svelte' + end + + def additional_entries + type = 'Svelte' + subtype = nil + css('h2, h3, h4').each_with_object [] do |node, entries| + if node.name == 'h2' + type = node.content.strip + 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' + entries << [name, node['id'], subtype || type] + end + end + end + end +end diff --git a/lib/docs/scrapers/svelte.rb b/lib/docs/scrapers/svelte.rb new file mode 100644 index 00000000..822f1847 --- /dev/null +++ b/lib/docs/scrapers/svelte.rb @@ -0,0 +1,28 @@ +module Docs + class Svelte < UrlScraper + self.name = 'Svelte' + self.slug = 'svelte' + self.type = 'simple' + self.links = { + home: 'https://svelte.dev/', + code: 'https://github.com/sveltejs/svelte' + } + + options[:root_title] = 'Svelte' + + options[:attribution] = <<-HTML + © 2016–2022 Rich Harris and contributors
+ Licensed under the MIT License. + HTML + + options[:skip] = %w(team.html plugins/) + + self.release = '3.50.1' + self.base_url = 'https://svelte.dev/docs' + html_filters.push 'svelte/entries', 'svelte/clean_html' + + def get_latest_version(opts) + get_npm_version('svelte', opts) + end + end +end diff --git a/public/icons/docs/svelte/16.png b/public/icons/docs/svelte/16.png new file mode 100644 index 00000000..d8482015 Binary files /dev/null and b/public/icons/docs/svelte/16.png differ diff --git a/public/icons/docs/svelte/16@2x.png b/public/icons/docs/svelte/16@2x.png new file mode 100644 index 00000000..d74293e1 Binary files /dev/null and b/public/icons/docs/svelte/16@2x.png differ diff --git a/public/icons/docs/svelte/SOURCE b/public/icons/docs/svelte/SOURCE new file mode 100644 index 00000000..b4d677f6 --- /dev/null +++ b/public/icons/docs/svelte/SOURCE @@ -0,0 +1 @@ +https://svelte.dev/favicon.png