diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 80955a57..46930e8e 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -745,6 +745,11 @@ credits = [ '2012-2018 The Qt Company Ltd', 'GFDL', 'https://doc.qt.io/qt-5/licensing.html' + ], [ + 'QUnit', + 'OpenJS Foundation and other contributors', + 'MIT', + 'https://raw.githubusercontent.com/qunitjs/qunit/main/LICENSE.txt' ], [ 'R', '1999–2012 R Foundation for Statistical Computing', diff --git a/lib/docs/filters/qunit/clean_html.rb b/lib/docs/filters/qunit/clean_html.rb new file mode 100644 index 00000000..eb104b5c --- /dev/null +++ b/lib/docs/filters/qunit/clean_html.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Docs + class Qunit + class CleanHtmlFilter < Filter + def call + @doc = at_css('.content[role="main"]') + css('.sidebar').remove + css('pre').each do |node| + node['data-language'] = 'javascript' + node.content = node.content + end + doc + end + end + end +end diff --git a/lib/docs/filters/qunit/entries.rb b/lib/docs/filters/qunit/entries.rb new file mode 100644 index 00000000..43de1c5a --- /dev/null +++ b/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 diff --git a/lib/docs/scrapers/qunit.rb b/lib/docs/scrapers/qunit.rb new file mode 100644 index 00000000..f0d649f5 --- /dev/null +++ b/lib/docs/scrapers/qunit.rb @@ -0,0 +1,39 @@ +# 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] = <<-HTML + © OpenJS Foundation and contributors.
+ Licensed under the MIT license. + HTML + + def get_latest_version(opts) + get_npm_version('qunit', opts) + end + end +end diff --git a/public/icons/docs/qunit/16.png b/public/icons/docs/qunit/16.png new file mode 100644 index 00000000..4d7fdb41 Binary files /dev/null and b/public/icons/docs/qunit/16.png differ diff --git a/public/icons/docs/qunit/16@2x.png b/public/icons/docs/qunit/16@2x.png new file mode 100644 index 00000000..b9ae2d2f Binary files /dev/null and b/public/icons/docs/qunit/16@2x.png differ diff --git a/public/icons/docs/qunit/SOURCE b/public/icons/docs/qunit/SOURCE new file mode 100644 index 00000000..560740c2 --- /dev/null +++ b/public/icons/docs/qunit/SOURCE @@ -0,0 +1 @@ +https://raw.githubusercontent.com/qunitjs/qunitjs.com/main/img/logo.svg