History

Add Requests documentation (2.28.1)

Simon Legner committed 4 years ago

Commit 16f42e71 parent 9e9fa2b9 files · +107 −0Browse files

Unified · Split

9 files
  1. assets/javascripts/news.json +1 −1
  2. assets/javascripts/templates/pages/about_tmpl.coffee +5 −0
  3. assets/stylesheets/pages/_sphinx.scss +1 −1
  4. lib/docs/filters/requests/entries.rb +75 −0
  5. lib/docs/filters/sphinx/clean_html.rb +1 −0
  6. lib/docs/scrapers/requests.rb +25 −0
  7. public/icons/docs/requests/16.png +0 −0
  8. public/icons/docs/requests/16@2x.png +0 −0
  9. public/icons/docs/requests/SOURCE +1 −0
assets/javascripts/news.json+1−1
@@ -1,7 +1,7 @@
1[1[
2 [2 [
3 "2022-08-27",3 "2022-08-27",
4 "New documentations: <a href=\"/sanctuary/\">Sanctuary</a>"4 "New documentations: <a href=\"/sanctuary/\">Sanctuary</a>, <a href=\"/requests/\">Requests</a>"
5 ],5 ],
6 [6 [
7 "2022-05-03",7 "2022-05-03",
assets/javascripts/templates/pages/about_tmpl.coffee+5−0
@@ -766,6 +766,11 @@ credits = [ · 765 unmodified lines
766 '2015-2022 Dan Abramov',766 '2015-2022 Dan Abramov',
767 'MIT',767 'MIT',
768 'https://raw.githubusercontent.com/reactjs/redux/master/LICENSE.md'768 'https://raw.githubusercontent.com/reactjs/redux/master/LICENSE.md'
769 ], [
770 'Requests',
771 '2011-2022 Kenneth Reitz and other contributors',
772 'Apache',
773 'https://raw.githubusercontent.com/psf/requests/main/LICENSE'
769 ], [774 ], [
770 'RequireJS',775 'RequireJS',
771 'jQuery Foundation and other contributors',776 'jQuery Foundation and other contributors',
assets/stylesheets/pages/_sphinx.scss+1−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
4 h4 { font-size: 1em; }4 h4 { font-size: 1em; }
5 > dl:not(.docutils) > dt { @extend %block-label, %label-blue; }5 > dl:not(.docutils) > dt { @extend %block-label, %label-blue; }
6 dd > dl:not(.docutils) > dt { @extend %block-label; }6 dd > dl:not(.docutils) > dt { @extend %block-label; }
7 .class > dt { @extend %block-label, %label-blue; }7 .class > dt, #main-interface .function > dt { @extend %block-label, %label-blue; }
8 dt + dt { margin-top: -.5em; }8 dt + dt { margin-top: -.5em; }
9 9
10 .note, .admonition, div.versionadded, div.versionchanged, .deprecated-removed, .deprecated, .topic { @extend %note; }10 .note, .admonition, div.versionadded, div.versionchanged, .deprecated-removed, .deprecated, .topic { @extend %note; }
lib/docs/filters/requests/entries.rb+75−0
@@ -0,0 +1,75 @@
1module Docs
2 class Requests
3 class EntriesFilter < Docs::EntriesFilter
4 TYPE_BY_SLUG = {}
5
6 def call
7 if root_page?
8 css('.section').each do |node|
9 type = node.at_css('h2').content[0..-2]
10 node.css('li > a').each do |n|
11 s = n['href'].split('/')[-2]
12 TYPE_BY_SLUG[s] = type
13 end
14 end
15 end
16 super
17 end
18
19 def get_name
20 at_css('h1').content[0..-2]
21 end
22
23 def get_type
24 TYPE_BY_SLUG[slug.split('/').first] || 'Other'
25 end
26
27 def include_default_entry?
28 slug != 'api/'
29 end
30
31 def additional_entries
32 entries = []
33 css('dl.function > dt[id]').each do |node|
34 name = node['id'].split('.').last + '()'
35 id = node['id']
36 type = node['id'].split('.')[0..-2].join('.')
37 entries << [name, id, type]
38 end
39
40 css('dl.class > dt[id]').each do |node|
41 name = node['id'].split('.').last
42 id = node['id']
43 type = node['id'].split('.')[0..-2].join('.')
44 entries << [name, id, type]
45 end
46
47 css('dl.attribute > dt[id]').each do |node|
48 name = node['id'].split('.')[-2..-1].join('.')
49 id = node['id']
50 type = node['id'].split('.')[0..-3].join('.')
51 type = 'requests' if type == ''
52 entries << [name, id, type]
53 end
54
55 css('dl.data > dt[id]').each do |node|
56 name = node['id']
57 id = node['id']
58 type = node['id'].split('.')[0..-3].join('.')
59 type = 'requests' if type == ''
60 type = 'Configuration' if slug == 'config/'
61 entries << [name, id, type]
62 end
63
64 css('dl.method > dt[id]').each do |node|
65 name = node['id'].split('.')[-2..-1].join('.') + '()'
66 id = node['id']
67 type = node['id'].split('.')[0..-3].join('.')
68 entries << [name, id, type]
69 end
70 entries
71 end
72
73 end
74 end
75end
lib/docs/filters/sphinx/clean_html.rb+1−0
@@ -60,6 +60,7 @@ module Docs · 59 unmodified lines
60 css('dt').each do |node|60 css('dt').each do |node|
61 next if current_url.host == 'matplotlib.org'61 next if current_url.host == 'matplotlib.org'
62 next if current_url.host == 'numpy.org'62 next if current_url.host == 'numpy.org'
63 next if current_url.host == 'requests.readthedocs.io'
63 next unless node['id'] || node.at_css('code, .classifier')64 next unless node['id'] || node.at_css('code, .classifier')
64 links = []65 links = []
65 links << node.children.last.remove while node.children.last.try(:name) == 'a'66 links << node.children.last.remove while node.children.last.try(:name) == 'a'
lib/docs/scrapers/requests.rb+25−0
@@ -0,0 +1,25 @@
1module Docs
2 class Requests < UrlScraper
3 self.type = 'sphinx'
4 self.root_path = 'index.html'
5 self.links = {
6 home: 'https://requests.readthedocs.io/',
7 code: 'https://github.com/psf/requests'
8 }
9 self.release = '2.28.1'
10 self.base_url = "https://requests.readthedocs.io/en/latest/api/"
11
12 html_filters.push 'requests/entries', 'sphinx/clean_html'
13
14 options[:container] = '.body > section'
15
16 options[:attribution] = <<-HTML
17 &copy; 2011-2022 Kenneth Reitz and other contributors<br>
18 Licensed under the Apache license.
19 HTML
20
21 def get_latest_version(opts)
22 get_latest_github_release('psf', 'requests', opts)
23 end
24 end
25end
public/icons/docs/requests/16.png+0−0

Binary file not shown.

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

Binary file not shown.

public/icons/docs/requests/SOURCE+1−0
@@ -0,0 +1 @@
1https://requests.readthedocs.io/en/latest/_static/requests-sidebar.png