mirror of https://github.com/freeCodeCamp/devdocs
parent
9e9fa2ba28
commit
16f42e7780
@ -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
|
@ -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<br>
|
||||
Licensed under the Apache license.
|
||||
HTML
|
||||
|
||||
def get_latest_version(opts)
|
||||
get_latest_github_release('psf', 'requests', opts)
|
||||
end
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 2.4 KiB |
@ -0,0 +1 @@
|
||||
https://requests.readthedocs.io/en/latest/_static/requests-sidebar.png
|
Loading…
Reference in new issue