From 131f97a918660b2e11b072f5cef132defb4e991d Mon Sep 17 00:00:00 2001 From: Cimbali Date: Fri, 17 May 2024 12:10:36 +0200 Subject: [PATCH] Add click documentation --- lib/docs/filters/click/clean_html.rb | 15 ++++++++ lib/docs/filters/click/entries.rb | 45 +++++++++++++++++++++++ lib/docs/filters/click/pre_clean_html.rb | 11 ++++++ lib/docs/scrapers/click.rb | 29 +++++++++++++++ public/icons/docs/click/16.png | Bin 0 -> 641 bytes public/icons/docs/click/16@2x.png | Bin 0 -> 797 bytes public/icons/docs/click/SOURCE | 1 + 7 files changed, 101 insertions(+) create mode 100644 lib/docs/filters/click/clean_html.rb create mode 100644 lib/docs/filters/click/entries.rb create mode 100644 lib/docs/filters/click/pre_clean_html.rb create mode 100644 lib/docs/scrapers/click.rb create mode 100644 public/icons/docs/click/16.png create mode 100644 public/icons/docs/click/16@2x.png create mode 100644 public/icons/docs/click/SOURCE diff --git a/lib/docs/filters/click/clean_html.rb b/lib/docs/filters/click/clean_html.rb new file mode 100644 index 00000000..914ee6b4 --- /dev/null +++ b/lib/docs/filters/click/clean_html.rb @@ -0,0 +1,15 @@ +module Docs + class Click + class CleanHtmlFilter < Filter + def call + if root_page? + # Image renders quite badly in dark mode + at_css('h1 + a.image-reference').remove + # All superfluous + css('#documentation, #api-reference, #miscellaneous-pages').remove + end + doc + end + end + end +end diff --git a/lib/docs/filters/click/entries.rb b/lib/docs/filters/click/entries.rb new file mode 100644 index 00000000..09b3a761 --- /dev/null +++ b/lib/docs/filters/click/entries.rb @@ -0,0 +1,45 @@ +module Docs + class Click + class EntriesFilter < Docs::EntriesFilter + + def initialize(*) + super + end + + def get_name + return at_css('h1').content.strip + end + + def get_type + return at_css('h1').content.strip + end + + def include_default_entry? + false + end + + def additional_entries + return [] if root_page? + + if slug == 'api/' + entries = [] + doc.css('> section').each do |section| + title = section.at_css('h2').content.strip + section.css('> dl.py > dt[id]').each do |dt| + entries << [dt['id'], dt['id'], title] + end + end + return entries + end + + (doc.css('> section') || []).map do |section| + title = section.at_css('h2').content.strip + [title, section['id']] + end + end + + private + + end + end +end diff --git a/lib/docs/filters/click/pre_clean_html.rb b/lib/docs/filters/click/pre_clean_html.rb new file mode 100644 index 00000000..6413aa61 --- /dev/null +++ b/lib/docs/filters/click/pre_clean_html.rb @@ -0,0 +1,11 @@ +module Docs + class Click + class PreCleanHtmlFilter < Filter + def call + # Remove ΒΆ character from tag w/ name & type + css('.headerlink').remove + doc + end + end + end +end diff --git a/lib/docs/scrapers/click.rb b/lib/docs/scrapers/click.rb new file mode 100644 index 00000000..7e0121cc --- /dev/null +++ b/lib/docs/scrapers/click.rb @@ -0,0 +1,29 @@ +module Docs + class Click < UrlScraper + self.name = 'click' + self.type = 'sphinx' #'simple' + self.release = '8.1.7' + self.base_url = 'https://click.palletsprojects.com/en/8.1.x/' + self.root_path = 'index.html' + self.links = { + home: 'https://click.palletsprojects.com/', + code: 'https://github.com/pallets/click' + } + + html_filters.push 'click/pre_clean_html', 'click/entries', 'click/clean_html', 'sphinx/clean_html', 'title' + + options[:skip] = ['changes/', 'genindex/', 'py-modindex/', 'license/'] + options[:container] = '.body > section' + options[:title] = false + + options[:attribution] = <<-HTML + © Copyright 2014 Pallets.
+ Licensed under the BSD 3-Clause License.
+ We are not supported nor endorsed by Pallets. + HTML + + def get_latest_version(opts) + get_latest_github_release('pallets', 'click', opts) + end + end +end diff --git a/public/icons/docs/click/16.png b/public/icons/docs/click/16.png new file mode 100644 index 0000000000000000000000000000000000000000..d1497c30c0c30a981c9956370eee509d2a5f7341 GIT binary patch literal 641 zcmV-{0)G98P)EX>4Tx04R}tkv&MmKpe$iTT4Z%B6bjQ2vVKwq9Ts93Pq?8YK2xEOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4P#J2)x2NQwVT3N2zhIPS;0dyl(!fWJ{;s@W9>RLwHd z$%K&2tqP%61Tla<#4su`Q=b#X6g)J&;^Mfxh}i>#<}RQpJzslOnRO;LM#+JSngm}GF0Me;;5o(l<&{F ztZ?4qtX68Qbx;1na9&$k<~q$0B(aDkh!7y7hB7L!sIM|KQcR?2KjGmYcKjl_WO9|k z$gzMbR7j2={11M2YZj&^-K1~=2)@|%#~2XW1)6o+{yw(t<_QpZ2ClTWzuEw1KS{5* zwdfJhzYSbmw>5bWxZDATo^;8O94SE4Unl_YXY@@uVDJ{`S#x`9?c?+T$WT|Q8{ps& z7%x)xy2rb_JA3>0Osl^iyz+9yfFmui00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=milDFAnLvw50$50DehCK~y-)?b0y{!cY)|;qRG; z7)T-F3A~aP_Ff=uE|Vi@>pASjTJQj3qs?L=C`k$nahidJe|MH${`x_!Fd7Q4aX^jK z7cQ{HxG!9U-*H2OBhEwDm|=%$S0INcY_Pxu*O!z_%%eWR3HwO?RD~Ahn?X6600000NkvXXu0mjf7?KhQ literal 0 HcmV?d00001 diff --git a/public/icons/docs/click/16@2x.png b/public/icons/docs/click/16@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..3bc91ffbd56e0e6075714c6b4131c1e06c140c54 GIT binary patch literal 797 zcmV+&1LFLNP)EX>4Tx04R}tkv&MmKpe$iTT4Z%B6bjQ2vVKwq9Ts93Pq?8YK2xEOfLO`CJjl7 zi=*ILaPVWX>fqw6tAnc`2!4P#J2)x2NQwVT3N2zhIPS;0dyl(!fWJ{;s@W9>RLwHd z$%K&2tqP%61Tla<#4su`Q=b#X6g)J&;^Mfxh}i>#<}RQpJzslOnRO;LM#+JSngm}GF0Me;;5o(l<&{F ztZ?4qtX68Qbx;1na9&$k<~q$0B(aDkh!7y7hB7L!sIM|KQcR?2KjGmYcKjl_WO9|k z$gzMbR7j2={11M2YZj&^-K1~=2)@|%#~2XW1)6o+{yw(t<_QpZ2ClTWzuEw1KS{5* zwdfJhzYSbmw>5bWxZDATo^;8O94SE4Unl_YXY@@uVDJ{`S#x`9?c?+T$WT|Q8{ps& z7%x)xy2rb_JA3>0Osl^iyz+9yfFmui00006VoOIv0RI600RN!9r;`8x010qNS#tmY z3ljhU3ljkVnw%H_000McNliru=milDE<2_aLB{|90UAj}K~z}7?bN$U13?tV@n7zW z#?DF+TN_Jl1q;!)u(Ov`zJZ0kot9#wU>)!Q?6eUP#74mz+8D?tHWQF#6Jn7p$oyeo zIWT)J^L>X%Boc{4BK@gjKF;n6Bn?I8+_vcOQT9w%7|^@6mPh~3_fvq8v_PR0+!&rga0MTD9^zlWr_@b7t03yupaM$R!wx2b6Yj8$hXKi_(7