History

Add click documentation

Cimbali committed 2 years ago

Commit 131f97a1 parent dec1cb27 files · +99 −-2Browse files

Unified · Split

7 files
  1. lib/docs/filters/click/clean_html.rb +15 −0
  2. lib/docs/filters/click/entries.rb +45 −0
  3. lib/docs/filters/click/pre_clean_html.rb +11 −0
  4. lib/docs/scrapers/click.rb +29 −0
  5. public/icons/docs/click/16.png +0 −0
  6. public/icons/docs/click/16@2x.png +0 −0
  7. public/icons/docs/click/SOURCE +1 −0
lib/docs/filters/click/clean_html.rb+15−0
@@ -0,0 +1,15 @@
1module Docs
2 class Click
3 class CleanHtmlFilter < Filter
4 def call
5 if root_page?
6 # Image renders quite badly in dark mode
7 at_css('h1 + a.image-reference').remove
8 # All superfluous
9 css('#documentation, #api-reference, #miscellaneous-pages').remove
10 end
11 doc
12 end
13 end
14 end
15end
lib/docs/filters/click/entries.rb+45−0
@@ -0,0 +1,45 @@
1module Docs
2 class Click
3 class EntriesFilter < Docs::EntriesFilter
4
5 def initialize(*)
6 super
7 end
8
9 def get_name
10 return at_css('h1').content.strip
11 end
12
13 def get_type
14 return at_css('h1').content.strip
15 end
16
17 def include_default_entry?
18 false
19 end
20
21 def additional_entries
22 return [] if root_page?
23
24 if slug == 'api/'
25 entries = []
26 doc.css('> section').each do |section|
27 title = section.at_css('h2').content.strip
28 section.css('> dl.py > dt[id]').each do |dt|
29 entries << [dt['id'], dt['id'], title]
30 end
31 end
32 return entries
33 end
34
35 (doc.css('> section') || []).map do |section|
36 title = section.at_css('h2').content.strip
37 [title, section['id']]
38 end
39 end
40
41 private
42
43 end
44 end
45end
lib/docs/filters/click/pre_clean_html.rb+11−0
@@ -0,0 +1,11 @@
1module Docs
2 class Click
3 class PreCleanHtmlFilter < Filter
4 def call
5 # Remove ¶ character from tag w/ name & type
6 css('.headerlink').remove
7 doc
8 end
9 end
10 end
11end
lib/docs/scrapers/click.rb+29−0
@@ -0,0 +1,29 @@
1module Docs
2 class Click < UrlScraper
3 self.name = 'click'
4 self.type = 'sphinx' #'simple'
5 self.release = '8.1.7'
6 self.base_url = 'https://click.palletsprojects.com/en/8.1.x/'
7 self.root_path = 'index.html'
8 self.links = {
9 home: 'https://click.palletsprojects.com/',
10 code: 'https://github.com/pallets/click'
11 }
12
13 html_filters.push 'click/pre_clean_html', 'click/entries', 'click/clean_html', 'sphinx/clean_html', 'title'
14
15 options[:skip] = ['changes/', 'genindex/', 'py-modindex/', 'license/']
16 options[:container] = '.body > section'
17 options[:title] = false
18
19 options[:attribution] = <<-HTML
20 &copy; Copyright 2014 Pallets.<br>
21 Licensed under the BSD 3-Clause License.<br>
22 We are not supported nor endorsed by Pallets.
23 HTML
24
25 def get_latest_version(opts)
26 get_latest_github_release('pallets', 'click', opts)
27 end
28 end
29end
public/icons/docs/click/16.png+0−0

Binary file not shown.

public/icons/docs/click/16@2x.png+0−0

Binary file not shown.

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