Răsfoiți Sursa

add qunit documentation scraper

Vadim Kazakov 3 ani în urmă
părinte
comite
85bbd1ce6a

+ 12 - 0
lib/docs/filters/qunit/clean_html.rb

@@ -0,0 +1,12 @@
+# frozen_string_literal: true
+
+module Docs
+  class Qunit
+    class CleanHtmlFilter < Filter
+      def call
+        css('.sidebar').remove
+        doc
+      end
+    end
+  end
+end

+ 23 - 0
lib/docs/filters/qunit/entries.rb

@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Docs
+  class Qunit
+    class EntriesFilter < Docs::EntriesFilter
+      TYPE_MAPPING = {
+        'QUnit' => '1. Main methods',
+        'assert' => '2. Assertions',
+        'callbacks' => '3. Callback events',
+        'config' => '4. Configuration',
+        'extension' => '5. Extension interface'
+      }
+      def get_name
+        at_css('h1').content
+      end
+
+      def get_type
+        main, *rest = *slug.split('/')
+        TYPE_MAPPING[main]
+      end
+    end
+  end
+end

+ 32 - 0
lib/docs/scrapers/qunit.rb

@@ -0,0 +1,32 @@
+# frozen_string_literal: true
+
+module Docs
+  class Qunit < UrlScraper
+    self.name = 'QUnit'
+    self.type = 'qunit'
+    self.release = '2.19.3'
+    self.base_url = 'https://api.qunitjs.com/'
+    self.root_path = '/'
+    self.links = {
+      home: 'https://qunitjs.com/',
+      code: 'https://github.com/qunitjs/qunit'
+    }
+
+    html_filters.push 'qunit/entries', 'qunit/clean_html'
+
+    options[:trailing_slash] = false
+
+    options[:container] = '.main'
+    options[:skip_patterns] = [
+      /deprecated/,
+      /^QUnit$/,
+      /^assert$/,
+      /^callbacks$/,
+      /^async$/,
+      /^config$/,
+      /^extension$/,
+    ]
+
+    options[:attribution] = 'Copyright OpenJS Foundation and contributors.'
+  end
+end

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


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


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

@@ -0,0 +1 @@
+https://raw.githubusercontent.com/qunitjs/qunitjs.com/main/img/logo.svg