Browse Source

Add click documentation

Cimbali 1 year ago
parent
commit
131f97a918

+ 15 - 0
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

+ 45 - 0
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

+ 11 - 0
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

+ 29 - 0
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
+      &copy; Copyright 2014 Pallets.<br>
+      Licensed under the BSD 3-Clause License.<br>
+      We are not supported nor endorsed by Pallets.
+    HTML
+
+    def get_latest_version(opts)
+      get_latest_github_release('pallets', 'click', opts)
+    end
+  end
+end

BIN
public/icons/docs/click/16.png


BIN
public/icons/docs/click/16@2x.png


+ 1 - 0
public/icons/docs/click/SOURCE

@@ -0,0 +1 @@
+https://github.com/pallets/click/blob/main/docs/_static/click-icon.png