django_rest_framework: finish scraper and filters

pull/1003/head
Jasper van Merle 6 years ago
parent 14049dac0c
commit cbe38c8f36

@ -231,6 +231,11 @@ credits = [
'Django Software Foundation and individual contributors', 'Django Software Foundation and individual contributors',
'BSD', 'BSD',
'https://raw.githubusercontent.com/django/django/master/LICENSE' 'https://raw.githubusercontent.com/django/django/master/LICENSE'
], [
'Django REST Framework',
'2011-present Encode OSS Ltd.',
'BSD',
'https://raw.githubusercontent.com/encode/django-rest-framework/master/LICENSE.md'
], [ ], [
'Docker', 'Docker',
'2019 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.', '2019 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',

@ -1,14 +1,14 @@
module Docs module Docs
class RestFramework class DjangoRestFramework
class CleanHtmlFilter < Docs::Filter class CleanHtmlFilter < Docs::Filter
def call def call
css('hr').remove css('hr').remove
css('.badges').remove css('.badges').remove
css('pre').attr('data-language', 'python') css('pre').attr('data-language', 'python')
css('h1').attr('style', nil) css('h1').remove_attribute('style')
css('.promo a').remove_attribute('style')
# Translate source files links to DevDocs links # Translate source files links to DevDocs links
links = Nokogiri::XML::Node.new('p', doc) links = Nokogiri::XML::Node.new('p', doc)
@ -20,6 +20,7 @@ module Docs
node['class'] = '_links-link' node['class'] = '_links-link'
links.add_child(node) links.add_child(node)
end end
doc.add_child(links) doc.add_child(links)
doc doc

@ -1,7 +1,6 @@
module Docs module Docs
class RestFramework class DjangoRestFramework
class EntriesFilter < Docs::EntriesFilter class EntriesFilter < Docs::EntriesFilter
def get_name def get_name
name = css('h1').first.content name = css('h1').first.content
name.slice! 'Tutorial ' name.slice! 'Tutorial '
@ -46,7 +45,7 @@ module Docs
next next
end end
entries << [node.content, node['id'], local_type] entries << [node.content, node['id'], local_type]
elsif accepted_headers.include? node.content elsif accepted_headers.include? node.content
in_category = true in_category = true
elsif endings.any? { |word| node.content.ends_with?(word) } elsif endings.any? { |word| node.content.ends_with?(word) }
entries << [node.content, node['id'], local_type] entries << [node.content, node['id'], local_type]

@ -1,8 +1,8 @@
module Docs module Docs
class RestFramework < Mkdocs class DjangoRestFramework < Mkdocs
self.name = 'Django REST Framework' self.name = 'Django REST Framework'
self.release = '3.9.2' self.release = '3.9.3'
self.slug = 'rest_framework' self.slug = 'django_rest_framework'
self.base_url = 'https://www.django-rest-framework.org/' self.base_url = 'https://www.django-rest-framework.org/'
self.root_path = 'index.html' self.root_path = 'index.html'
self.links = { self.links = {
@ -10,7 +10,7 @@ module Docs
code: 'https://github.com/encode/django-rest-framework' code: 'https://github.com/encode/django-rest-framework'
} }
html_filters.push 'rest_framework/clean_html', 'rest_framework/entries' html_filters.push 'django_rest_framework/clean_html', 'django_rest_framework/entries'
options[:skip_patterns] = [ options[:skip_patterns] = [
/\Atopics\//, /\Atopics\//,
@ -18,8 +18,12 @@ module Docs
] ]
options[:attribution] = <<-HTML options[:attribution] = <<-HTML
Copyright 2011&ndash;present Encode OSS Ltd<br> Copyright 2011&ndash;present Encode OSS Ltd.<br>
Licensed under the BSD License. Licensed under the BSD License.
HTML HTML
def get_latest_version(opts)
get_latest_github_release('encode', 'django-rest-framework', opts)
end
end end
end end

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Loading…
Cancel
Save