[devdocsgjs/main: 36/69] Add Requests documentation (2.28.1)




commit 16f42e778026345e785bb07b7a5513e5490d4c01
Author: Simon Legner <Simon Legner gmail com>
Date:   Sat Aug 27 20:45:51 2022 +0200

    Add Requests documentation (2.28.1)

 assets/javascripts/news.json                       |   2 +-
 .../javascripts/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(-)
---
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: <a href=\"/sanctuary/\">Sanctuary</a>"
+    "New documentations: <a href=\"/sanctuary/\">Sanctuary</a>, <a href=\"/requests/\">Requests</a>"
   ],
   [
     "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
+      &copy; 2011-2022 Kenneth Reitz and other contributors<br>
+      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 00000000..e423927a
Binary files /dev/null and b/public/icons/docs/requests/16.png differ
diff --git a/public/icons/docs/requests/16 2x png b/public/icons/docs/requests/16 2x png
new file mode 100644
index 00000000..06a4550f
Binary files /dev/null and b/public/icons/docs/requests/16 2x png differ
diff --git a/public/icons/docs/requests/SOURCE b/public/icons/docs/requests/SOURCE
new file mode 100644
index 00000000..eeae972f
--- /dev/null
+++ b/public/icons/docs/requests/SOURCE
@@ -0,0 +1 @@
+https://requests.readthedocs.io/en/latest/_static/requests-sidebar.png


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]