浏览代码

Use Mkdocs as base for RestFramework

Emil Maruszczak 6 年之前
父节点
当前提交
8fdaf8a33c
共有 2 个文件被更改,包括 17 次插入14 次删除
  1. 15 1
      lib/docs/scrapers/mkdocs.rb
  2. 2 13
      lib/docs/scrapers/rest_framework.rb

+ 15 - 1
lib/docs/scrapers/mkdocs.rb

@@ -1,5 +1,19 @@
 module Docs
-  class Mkdocs < Scraper
+  class Mkdocs < UrlScraper
     self.abstract = true
+    self.type = 'mkdocs'
+
+    html_filters.push 'mkdocs/clean_html'
+
+    private
+
+    def handle_response(response)
+      # Some scrapped urls don't have ending slash
+      # which leads to page duplication
+      if !response.url.path.ends_with?('/') && !response.url.path.ends_with?('index.html')
+        response.url.path << '/'
+      end
+      super
+    end
   end
 end

+ 2 - 13
lib/docs/scrapers/rest_framework.rb

@@ -1,5 +1,5 @@
 module Docs
-  class RestFramework < UrlScraper
+  class RestFramework < Mkdocs
     self.name = 'Django REST Framework'
     self.release = '3.9.2'
     self.slug = 'rest_framework'
@@ -11,7 +11,7 @@ module Docs
       code: 'https://github.com/encode/django-rest-framework'
     }
 
-    html_filters.push 'mkdocs/clean_html', 'rest_framework/clean_html', 'rest_framework/entries'
+    html_filters.push 'rest_framework/clean_html', 'rest_framework/entries'
 
     options[:skip_patterns] = [
       /\Atopics\//,
@@ -22,16 +22,5 @@ module Docs
       Copyright 2011&ndash;present Encode OSS Ltd<br>
       Licensed under the BSD License.
     HTML
-
-    private
-
-    def handle_response(response)
-      # Some scrapped urls don't have ending slash
-      # which leads to page duplication
-      if !response.url.path.ends_with?('/') && !response.url.path.ends_with?('index.html')
-        response.url.path << '/'
-      end
-      super
-    end
   end
 end