From 16f42e778026345e785bb07b7a5513e5490d4c01 Mon Sep 17 00:00:00 2001 From: Simon Legner Date: Sat, 27 Aug 2022 20:45:51 +0200 Subject: [PATCH] Add Requests documentation (2.28.1) --- assets/javascripts/news.json | 2 +- .../templates/pages/about_tmpl.coffee | 5 ++ assets/stylesheets/pages/_sphinx.scss | 2 +- lib/docs/filters/requests/entries.rb | 75 ++++++++++++++++++ lib/docs/filters/sphinx/clean_html.rb | 1 + lib/docs/scrapers/requests.rb | 25 ++++++ public/icons/docs/requests/16.png | Bin 0 -> 1092 bytes public/icons/docs/requests/16@2x.png | Bin 0 -> 2484 bytes public/icons/docs/requests/SOURCE | 1 + 9 files changed, 109 insertions(+), 2 deletions(-) create mode 100755 lib/docs/filters/requests/entries.rb create mode 100755 lib/docs/scrapers/requests.rb create mode 100644 public/icons/docs/requests/16.png create mode 100644 public/icons/docs/requests/16@2x.png create mode 100644 public/icons/docs/requests/SOURCE diff --git a/assets/javascripts/news.json b/assets/javascripts/news.json index 43958e1a..077180c9 100644 --- a/assets/javascripts/news.json +++ b/assets/javascripts/news.json @@ -1,7 +1,7 @@ [ [ "2022-08-27", - "New documentations: Sanctuary" + "New documentations: Sanctuary, Requests" ], [ "2022-05-03", diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 20dd3f84..b3b7136c 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -766,6 +766,11 @@ credits = [ '2015-2022 Dan Abramov', 'MIT', 'https://raw.githubusercontent.com/reactjs/redux/master/LICENSE.md' + ], [ + 'Requests', + '2011-2022 Kenneth Reitz and other contributors', + 'Apache', + 'https://raw.githubusercontent.com/psf/requests/main/LICENSE' ], [ 'RequireJS', 'jQuery Foundation and other contributors', diff --git a/assets/stylesheets/pages/_sphinx.scss b/assets/stylesheets/pages/_sphinx.scss index f51e161d..64a4df6b 100644 --- a/assets/stylesheets/pages/_sphinx.scss +++ b/assets/stylesheets/pages/_sphinx.scss @@ -4,7 +4,7 @@ h4 { font-size: 1em; } > dl:not(.docutils) > dt { @extend %block-label, %label-blue; } dd > dl:not(.docutils) > dt { @extend %block-label; } - .class > dt { @extend %block-label, %label-blue; } + .class > dt, #main-interface .function > dt { @extend %block-label, %label-blue; } dt + dt { margin-top: -.5em; } .note, .admonition, div.versionadded, div.versionchanged, .deprecated-removed, .deprecated, .topic { @extend %note; } diff --git a/lib/docs/filters/requests/entries.rb b/lib/docs/filters/requests/entries.rb new file mode 100755 index 00000000..2bf7e219 --- /dev/null +++ b/lib/docs/filters/requests/entries.rb @@ -0,0 +1,75 @@ +module Docs + class Requests + class EntriesFilter < Docs::EntriesFilter + TYPE_BY_SLUG = {} + + def call + if root_page? + css('.section').each do |node| + type = node.at_css('h2').content[0..-2] + node.css('li > a').each do |n| + s = n['href'].split('/')[-2] + TYPE_BY_SLUG[s] = type + end + end + end + super + end + + def get_name + at_css('h1').content[0..-2] + end + + def get_type + TYPE_BY_SLUG[slug.split('/').first] || 'Other' + end + + def include_default_entry? + slug != 'api/' + end + + def additional_entries + entries = [] + css('dl.function > dt[id]').each do |node| + name = node['id'].split('.').last + '()' + id = node['id'] + type = node['id'].split('.')[0..-2].join('.') + entries << [name, id, type] + end + + css('dl.class > dt[id]').each do |node| + name = node['id'].split('.').last + id = node['id'] + type = node['id'].split('.')[0..-2].join('.') + entries << [name, id, type] + end + + css('dl.attribute > dt[id]').each do |node| + name = node['id'].split('.')[-2..-1].join('.') + id = node['id'] + type = node['id'].split('.')[0..-3].join('.') + type = 'requests' if type == '' + entries << [name, id, type] + end + + css('dl.data > dt[id]').each do |node| + name = node['id'] + id = node['id'] + type = node['id'].split('.')[0..-3].join('.') + type = 'requests' if type == '' + type = 'Configuration' if slug == 'config/' + entries << [name, id, type] + end + + css('dl.method > dt[id]').each do |node| + name = node['id'].split('.')[-2..-1].join('.') + '()' + id = node['id'] + type = node['id'].split('.')[0..-3].join('.') + entries << [name, id, type] + end + entries + end + + end + end +end diff --git a/lib/docs/filters/sphinx/clean_html.rb b/lib/docs/filters/sphinx/clean_html.rb index 048f6d3b..55cd5c0d 100644 --- a/lib/docs/filters/sphinx/clean_html.rb +++ b/lib/docs/filters/sphinx/clean_html.rb @@ -60,6 +60,7 @@ module Docs css('dt').each do |node| next if current_url.host == 'matplotlib.org' next if current_url.host == 'numpy.org' + next if current_url.host == 'requests.readthedocs.io' next unless node['id'] || node.at_css('code, .classifier') links = [] links << node.children.last.remove while node.children.last.try(:name) == 'a' diff --git a/lib/docs/scrapers/requests.rb b/lib/docs/scrapers/requests.rb new file mode 100755 index 00000000..d031e375 --- /dev/null +++ b/lib/docs/scrapers/requests.rb @@ -0,0 +1,25 @@ +module Docs + class Requests < UrlScraper + self.type = 'sphinx' + self.root_path = 'index.html' + self.links = { + home: 'https://requests.readthedocs.io/', + code: 'https://github.com/psf/requests' + } + self.release = '2.28.1' + self.base_url = "https://requests.readthedocs.io/en/latest/api/" + + html_filters.push 'requests/entries', 'sphinx/clean_html' + + options[:container] = '.body > section' + + options[:attribution] = <<-HTML + © 2011-2022 Kenneth Reitz and other contributors
+ Licensed under the Apache license. + HTML + + def get_latest_version(opts) + get_latest_github_release('psf', 'requests', opts) + end + end +end diff --git a/public/icons/docs/requests/16.png b/public/icons/docs/requests/16.png new file mode 100644 index 0000000000000000000000000000000000000000..e423927aa9ccd183b24ad02dbaebdfa1a8fa13c3 GIT binary patch literal 1092 zcmZ8ee=wVO82?Iys2{c7DQhpH`vccbFS6;(*$opB%G9sgtVp8ms$TTGy#*cF)*&rI z2nivH8)a9TbVH-Y30JaRr@M3$tP$}$V%F}CZGP?1{OfI3oqmWaAfu@GIEGe4LHtAv%pt_oD^+(cek* z4-9&X9`ttLDH<(^M$@I0$>5Id< zzqhxH#%EHgG%6|zD1^aa(ChUol`1JQIsHOL5w8elO-)T@XJOvnK83u3=;&w$gAo!E z0!0kViHL|uPiM1OtYHom@DntcVcu3LdZSS*&Jq8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