From bdec41f62615f6d717e0adca8a6bb386202710b1 Mon Sep 17 00:00:00 2001 From: Cimbali Date: Fri, 17 May 2024 17:29:38 +0200 Subject: [PATCH] Simplify processing, add multiple versions --- lib/docs/filters/click/clean_html.rb | 15 ------- lib/docs/filters/click/pre_clean_html.rb | 2 +- lib/docs/scrapers/click.rb | 53 +++++++++++++++++++++--- 3 files changed, 49 insertions(+), 21 deletions(-) delete mode 100644 lib/docs/filters/click/clean_html.rb diff --git a/lib/docs/filters/click/clean_html.rb b/lib/docs/filters/click/clean_html.rb deleted file mode 100644 index 914ee6b4..00000000 --- a/lib/docs/filters/click/clean_html.rb +++ /dev/null @@ -1,15 +0,0 @@ -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/pre_clean_html.rb b/lib/docs/filters/click/pre_clean_html.rb index 6413aa61..e0552a6a 100644 --- a/lib/docs/filters/click/pre_clean_html.rb +++ b/lib/docs/filters/click/pre_clean_html.rb @@ -2,7 +2,7 @@ module Docs class Click class PreCleanHtmlFilter < Filter def call - # Remove ¶ character from tag w/ name & type + # Remove ¶ character from headers css('.headerlink').remove doc end diff --git a/lib/docs/scrapers/click.rb b/lib/docs/scrapers/click.rb index 7e0121cc..ce5167f4 100644 --- a/lib/docs/scrapers/click.rb +++ b/lib/docs/scrapers/click.rb @@ -1,19 +1,17 @@ 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.type = 'sphinx' 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' + html_filters.push 'click/pre_clean_html', 'click/entries', 'sphinx/clean_html' - options[:skip] = ['changes/', 'genindex/', 'py-modindex/', 'license/'] options[:container] = '.body > section' + options[:skip] = ['changes/', 'genindex/', 'py-modindex/'] options[:title] = false options[:attribution] = <<-HTML @@ -22,6 +20,51 @@ module Docs We are not supported nor endorsed by Pallets. HTML + version '8.1' do + self.release = '8.1.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '8.0' do + self.release = '8.0.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '7' do + self.release = '7.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '6' do + self.release = '6.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '5' do + self.release = '5.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '4' do + self.release = '4.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '3' do + self.release = '3.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '2' do + self.release = '2.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + + version '1' do + self.release = '1.x' + self.base_url = "https://click.palletsprojects.com/en/#{self.release}/" + end + def get_latest_version(opts) get_latest_github_release('pallets', 'click', opts) end