浏览代码

django_rest_framework: finish scraper and filters

Jasper van Merle 6 年之前
父节点
当前提交
cbe38c8f36

+ 5 - 0
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -231,6 +231,11 @@ credits = [
     'Django Software Foundation and individual contributors',
     'BSD',
     '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',
     '2019 Docker, Inc.<br>Docker and the Docker logo are trademarks of Docker, Inc.',

+ 4 - 3
lib/docs/filters/rest_framework/clean_html.rb → lib/docs/filters/django_rest_framework/clean_html.rb

@@ -1,14 +1,14 @@
 module Docs
-  class RestFramework
+  class DjangoRestFramework
     class CleanHtmlFilter < Docs::Filter
       def call
         css('hr').remove
-
         css('.badges').remove
 
         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
         links = Nokogiri::XML::Node.new('p', doc)
@@ -20,6 +20,7 @@ module Docs
           node['class'] = '_links-link'
           links.add_child(node)
         end
+
         doc.add_child(links)
 
         doc

+ 2 - 3
lib/docs/filters/rest_framework/entries.rb → lib/docs/filters/django_rest_framework/entries.rb

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

+ 9 - 5
lib/docs/scrapers/rest_framework.rb → lib/docs/scrapers/mkdocs/django_rest_framework.rb

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

+ 0 - 0
lib/docs/scrapers/mkdocs.rb → lib/docs/scrapers/mkdocs/mkdocs.rb


+ 0 - 0
public/icons/docs/rest_framework/16.png → public/icons/docs/django_rest_framework/16.png


+ 0 - 0
public/icons/docs/rest_framework/16@2x.png → public/icons/docs/django_rest_framework/16@2x.png


+ 0 - 0
public/icons/docs/rest_framework/SOURCE → public/icons/docs/django_rest_framework/SOURCE