From 85bbd1ce6a77e9995432f62cfa43f6bb3b300d30 Mon Sep 17 00:00:00 2001 From: Vadim Kazakov Date: Fri, 16 Dec 2022 13:52:08 -0700 Subject: [PATCH 1/3] add qunit documentation scraper --- lib/docs/filters/qunit/clean_html.rb | 12 ++++++++++ lib/docs/filters/qunit/entries.rb | 23 +++++++++++++++++++ lib/docs/scrapers/qunit.rb | 32 +++++++++++++++++++++++++++ public/icons/docs/qunit/16.png | Bin 0 -> 1049 bytes public/icons/docs/qunit/16@2x.png | Bin 0 -> 1623 bytes public/icons/docs/qunit/SOURCE | 1 + 6 files changed, 68 insertions(+) create mode 100644 lib/docs/filters/qunit/clean_html.rb create mode 100644 lib/docs/filters/qunit/entries.rb create mode 100644 lib/docs/scrapers/qunit.rb create mode 100644 public/icons/docs/qunit/16.png create mode 100644 public/icons/docs/qunit/16@2x.png create mode 100644 public/icons/docs/qunit/SOURCE diff --git a/lib/docs/filters/qunit/clean_html.rb b/lib/docs/filters/qunit/clean_html.rb new file mode 100644 index 00000000..c85daaf8 --- /dev/null +++ b/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 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..f7cc13e1 --- /dev/null +++ b/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 diff --git a/public/icons/docs/qunit/16.png b/public/icons/docs/qunit/16.png new file mode 100644 index 0000000000000000000000000000000000000000..4d7fdb41bcf094761a570cbfbcb6850626ed1e5d GIT binary patch literal 1049 zcmV+!1m^pRP)EX>4Tx04R}tkv&MmKpe$iQ^gM|3T6;-$WWauii$XD6^c-y)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfbaGO3krMxx6k5c1aNLh~_a1le0HIc5n$?h)YYU4&=(pZjz4s9B2v0f~5)8KzCVK|H-_ z8=UuvMOKhi;&b9rlP*a7$aTfzH_myN1)eFIspLGdNG#=BSZQHaFg4;S;;^delrN+` zRyl8R)=CxDxF>&MD66k5bDic8Vpzly5|E&vf+9+=5usHl#X^$yqdxvY*PkGlLarhh zITlcc2HEw4|H1EWt=!~=bb{R9X;16O*}U#*53X-)9CL9b7OL+TD+Tr00006VoOIv0RI600RN!9r;`8x010qNS#tmY z4c7nw4c7reD4Tcy000McNliru<_r)NF*zGoY_|Xa0v1U`K~y-)os++7Q&AMhKR55? zz4WCt$xE69`}!*-t=g0#qF6;-0{RCCy1BRrT?9c?9CQ_&;!p%97dHhJp$O`tI5~*a z+NiZqo7hB?CN;Hr_d2BMFPovB>E8Rj_j5Vte2bKgFunsU2 zCh1!zi4De)u0*+twvffK^T$~!t?>2k=N$na05n1B!YHw1oWkrPk1svs!P)y{U(cW! zI?41P9?R1jphtBQM+T5m^7h^va*r0MzN?ab`3WTzZ9zZ66s-Y)(I6eM0L#THxfcuT zqTx3Y0#+(D)T#n)txF2tq!QtCu z7>>Cq1)moXn0^y2pdoaD7S`w-h~m~==3dRxeC7pXa%D7KBis|Awp7E4`3dX^@^NyC&XE|U{4d;6eFKo2{LcKDd7PAklj?@yrmMgT zS#*!};`JFsk`V&&Acb!QWToLQG0~S%O&<)N+lSq2cKIi@@c-1Tv^R T2uiB-00000NkvXXu0mjf!CT(T literal 0 HcmV?d00001 diff --git a/public/icons/docs/qunit/16@2x.png b/public/icons/docs/qunit/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..b9ae2d2ff64fa520c6f54013bfcdefd77a055128 GIT binary patch literal 1623 zcmV-d2B`UoP)EX>4Tx04R}tkv&MmKpe$iQ^gM|3T6;-$WWauii$XD6^c-y)C#RSm|Xe=O&XFE z7e~Rh;NZt%)xpJCR|i)?5c~jfbaGO3krMxx6k5c1aNLh~_a1le0HIc5n$?h)YYU4&=(pZjz4s9B2v0f~5)8KzCVK|H-_ z8=UuvMOKhi;&b9rlP*a7$aTfzH_myN1)eFIspLGdNG#=BSZQHaFg4;S;;^delrN+` zRyl8R)=CxDxF>&MD66k5bDic8Vpzly5|E&vf+9+=5usHl#X^$yqdxvY*PkGlLarhh zITlcc2HEw4|H1EWt=!~=bb{R9X;16O*}U#*53X-)9CL9b7OL+TD+Tr00006VoOIv0RI600RN!9r;`8x010qNS#tmY z4c7nw4c7reD4Tcy000McNliru<_r)NF(7|D#CHGy1XM{xK~z}7#g#hbX1Y5&XhIT1*g+0kUobNK{|DDVK9C4`qpbWeO z><3l=68BdMz!31BDVbl&z&_yP2VnR=aR3{DFC-gZ`OUrBwa0k`6&kS~x)rilzhxYR$4Hk@6w zAH|{egB70<>_rXqrtAiDd1E@hC z&%V_|us8Jo0jTR#=zg;YkKbckw@eE|H?VGty-Rho<<+f-MZ`g#kEgaAcoH?JmX>mv z9D~Px<*y?b(WW$%`JtptS$$kuBFw7pkwD6WRJ6?Up@0TV@F2kWVx9&xppyP zTl0l|)d3J5LEB?(wwMon{#%i~=ivoCrQh~9Q5^tZr=R+khLWC|m?3sLR`IgOXHU}X zjdXPYTKksSN-i;xz|zfmFIstv#&DplTNd%Fu_~&-f`-;cTdb3#(@=q?oQ+PFtXxvk z^`u7pmpE9Ubg9USOy)`kBc2BVYL^d(*FpOC6a}p?*8^6;LTONJM)ZVU5qaab0A7Dx zNso`k(MGa3oDTX9zQFFods*5WF1|A0WY>{B?D}jE-qyMbAuvJqI&GWodUr(tOE-jZ zxXRfX85l>n1m4a%lz;*PQdegH2yF@BY4noU4YJoW6#z(3m@U{gTQ;^L++yC$X??sr zMigcZE+4%FfPcLom+D5(Xr#}jinRVz3qlB{uO%=wbN(C<4ncZ4W!nsOG_&oKZic_P zh(4*8@(0pq9sVcm}P zs!)FP06`N9WB8hMc1cJsD#cG-Q^TwUa zFmi01*yZTlL$ZWZah1MXjRW|@ep(-0h9!fiuE-6ux{g(_P&fMUsvdIb9Mgk|I|HzE zlb=5Pk#zLl2}PUHNS>NTPZuj^ZTC8!>)*lC?>vJ`aigU*Qs-wD?uPN>QNE6R#pXAj zAl%i0yUvZn>9F?#i#aVhHWDSD$T9HgIn*Wanq=N2{b=To_R z?*+9GspznpNnQfZ*AT#I39NSky#~fpzyZmS%@C@?Qj$ VeJRk;Tde>9002ovPDHLkV1njj{3iea literal 0 HcmV?d00001 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 From faac2369cd580f355ce63b35ec8ac26de73edb26 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 20 Dec 2022 22:59:39 +0100 Subject: [PATCH 2/3] Update QUnit documentation (2.19.3) --- assets/javascripts/templates/pages/about_tmpl.coffee | 5 +++++ lib/docs/filters/qunit/clean_html.rb | 1 + lib/docs/scrapers/qunit.rb | 9 ++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 7ca88895..c9f07e19 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 index c85daaf8..201c30b6 100644 --- a/lib/docs/filters/qunit/clean_html.rb +++ b/lib/docs/filters/qunit/clean_html.rb @@ -4,6 +4,7 @@ module Docs class Qunit class CleanHtmlFilter < Filter def call + @doc = at_css('.content[role="main"]') css('.sidebar').remove doc end diff --git a/lib/docs/scrapers/qunit.rb b/lib/docs/scrapers/qunit.rb index f7cc13e1..f0d649f5 100644 --- a/lib/docs/scrapers/qunit.rb +++ b/lib/docs/scrapers/qunit.rb @@ -27,6 +27,13 @@ module Docs /^extension$/, ] - options[:attribution] = 'Copyright OpenJS Foundation and contributors.' + 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 From 1d0ffffd43b5d06624acc66f6aeb9d352a87887a Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Tue, 20 Dec 2022 23:00:52 +0100 Subject: [PATCH 3/3] Update QUnit documentation (2.19.3) --- lib/docs/filters/qunit/clean_html.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/docs/filters/qunit/clean_html.rb b/lib/docs/filters/qunit/clean_html.rb index 201c30b6..eb104b5c 100644 --- a/lib/docs/filters/qunit/clean_html.rb +++ b/lib/docs/filters/qunit/clean_html.rb @@ -6,6 +6,10 @@ module Docs 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