History

add qunit documentation scraper

Vadim Kazakov committed 3 years ago

Commit 85bbd1c1 parent c30fb316 files · +66 −-2Browse files

Unified · Split

6 files
  1. lib/docs/filters/qunit/clean_html.rb +12 −0
  2. lib/docs/filters/qunit/entries.rb +23 −0
  3. lib/docs/scrapers/qunit.rb +32 −0
  4. public/icons/docs/qunit/16.png +0 −0
  5. public/icons/docs/qunit/16@2x.png +0 −0
  6. public/icons/docs/qunit/SOURCE +1 −0
lib/docs/filters/qunit/clean_html.rb+12−0
@@ -0,0 +1,12 @@
1# frozen_string_literal: true
2
3module Docs
4 class Qunit
5 class CleanHtmlFilter < Filter
6 def call
7 css('.sidebar').remove
8 doc
9 end
10 end
11 end
12end
lib/docs/filters/qunit/entries.rb+23−0
@@ -0,0 +1,23 @@
1# frozen_string_literal: true
2
3module Docs
4 class Qunit
5 class EntriesFilter < Docs::EntriesFilter
6 TYPE_MAPPING = {
7 'QUnit' => '1. Main methods',
8 'assert' => '2. Assertions',
9 'callbacks' => '3. Callback events',
10 'config' => '4. Configuration',
11 'extension' => '5. Extension interface'
12 }
13 def get_name
14 at_css('h1').content
15 end
16
17 def get_type
18 main, *rest = *slug.split('/')
19 TYPE_MAPPING[main]
20 end
21 end
22 end
23end
lib/docs/scrapers/qunit.rb+32−0
@@ -0,0 +1,32 @@
1# frozen_string_literal: true
2
3module Docs
4 class Qunit < UrlScraper
5 self.name = 'QUnit'
6 self.type = 'qunit'
7 self.release = '2.19.3'
8 self.base_url = 'https://api.qunitjs.com/'
9 self.root_path = '/'
10 self.links = {
11 home: 'https://qunitjs.com/',
12 code: 'https://github.com/qunitjs/qunit'
13 }
14
15 html_filters.push 'qunit/entries', 'qunit/clean_html'
16
17 options[:trailing_slash] = false
18
19 options[:container] = '.main'
20 options[:skip_patterns] = [
21 /deprecated/,
22 /^QUnit$/,
23 /^assert$/,
24 /^callbacks$/,
25 /^async$/,
26 /^config$/,
27 /^extension$/,
28 ]
29
30 options[:attribution] = 'Copyright OpenJS Foundation and contributors.'
31 end
32end
public/icons/docs/qunit/16.png+0−0

Binary file not shown.

public/icons/docs/qunit/16@2x.png+0−0

Binary file not shown.

public/icons/docs/qunit/SOURCE+1−0
@@ -0,0 +1 @@
1https://raw.githubusercontent.com/qunitjs/qunitjs.com/main/img/logo.svg