Skip to content

Commit 8fdaf8a

Browse files
committed
Use Mkdocs as base for RestFramework
1 parent 14623be commit 8fdaf8a

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

lib/docs/scrapers/mkdocs.rb

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
module Docs
2-
class Mkdocs < Scraper
2+
class Mkdocs < UrlScraper
33
self.abstract = true
4+
self.type = 'mkdocs'
5+
6+
html_filters.push 'mkdocs/clean_html'
7+
8+
private
9+
10+
def handle_response(response)
11+
# Some scrapped urls don't have ending slash
12+
# which leads to page duplication
13+
if !response.url.path.ends_with?('/') && !response.url.path.ends_with?('index.html')
14+
response.url.path << '/'
15+
end
16+
super
17+
end
418
end
519
end

lib/docs/scrapers/rest_framework.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Docs
2-
class RestFramework < UrlScraper
2+
class RestFramework < Mkdocs
33
self.name = 'Django REST Framework'
44
self.release = '3.9.2'
55
self.slug = 'rest_framework'
@@ -11,7 +11,7 @@ class RestFramework < UrlScraper
1111
code: 'https://github.com/encode/django-rest-framework'
1212
}
1313

14-
html_filters.push 'mkdocs/clean_html', 'rest_framework/clean_html', 'rest_framework/entries'
14+
html_filters.push 'rest_framework/clean_html', 'rest_framework/entries'
1515

1616
options[:skip_patterns] = [
1717
/\Atopics\//,
@@ -22,16 +22,5 @@ class RestFramework < UrlScraper
2222
Copyright 2011&ndash;present Encode OSS Ltd<br>
2323
Licensed under the BSD License.
2424
HTML
25-
26-
private
27-
28-
def handle_response(response)
29-
# Some scrapped urls don't have ending slash
30-
# which leads to page duplication
31-
if !response.url.path.ends_with?('/') && !response.url.path.ends_with?('index.html')
32-
response.url.path << '/'
33-
end
34-
super
35-
end
3625
end
3726
end

0 commit comments

Comments
 (0)