Prechádzať zdrojové kódy

Add Svelte documentation (3.50.1)

Simon Legner 3 rokov pred
rodič
commit
8bbbb9e634

+ 4 - 0
assets/javascripts/news.json

@@ -1,4 +1,8 @@
 [
+  [
+    "2022-10-02",
+    "New documentation: <a href=\"/svelte/\">Svelte</a>"
+  ],
   [
     "2022-09-21",
     "Added HTTP/3 to <a href=\"/http/\">HTTP</a>"

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -871,6 +871,11 @@ credits = [
     '2009-2012 Statsmodels Developers<br>&copy; 2006-2008 Scipy Developers<br>&copy; 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',

+ 11 - 0
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

+ 27 - 0
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

+ 28 - 0
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
+      &copy; 2016–2022 Rich Harris and contributors<br>
+      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

BIN
public/icons/docs/svelte/16.png


BIN
public/icons/docs/svelte/16@2x.png


+ 1 - 0
public/icons/docs/svelte/SOURCE

@@ -0,0 +1 @@
+https://svelte.dev/favicon.png