History

django_rest_framework: finish scraper and filters

Jasper van Merle committed 7 years ago

Commit cbe38c81 parent 14049da8 files · +18 −9Browse files

Showing the changes to lib/docs (4 of 8 files). Show all

Unified · Split

4 files
  1. lib/docs/filters/django_rest_framework/clean_html.rb +4 −3
  2. lib/docs/filters/django_rest_framework/entries.rb +2 −3
  3. lib/docs/scrapers/mkdocs/django_rest_framework.rb +9 −5
  4. lib/docs/scrapers/mkdocs/mkdocs.rb +0 −0
lib/docs/filters/django_rest_framework/clean_html.rbrenamed from lib/docs/filters/rest_framework/clean_html.rb+4−3
@@ -1,14 +1,14 @@
1module Docs1module Docs
2 class RestFramework2 class DjangoRestFramework
3 class CleanHtmlFilter < Docs::Filter3 class CleanHtmlFilter < Docs::Filter
4 def call4 def call
5 css('hr').remove5 css('hr').remove
6
7 css('.badges').remove6 css('.badges').remove
8 7
9 css('pre').attr('data-language', 'python')8 css('pre').attr('data-language', 'python')
10 9
11 css('h1').attr('style', nil)10 css('h1').remove_attribute('style')
11 css('.promo a').remove_attribute('style')
12 12
13 # Translate source files links to DevDocs links13 # Translate source files links to DevDocs links
14 links = Nokogiri::XML::Node.new('p', doc)14 links = Nokogiri::XML::Node.new('p', doc)
@@ -20,6 +20,7 @@ module Docs · 5 unmodified lines
20 node['class'] = '_links-link'20 node['class'] = '_links-link'
21 links.add_child(node)21 links.add_child(node)
22 end22 end
23
23 doc.add_child(links)24 doc.add_child(links)
24 25
25 doc26 doc
lib/docs/filters/django_rest_framework/entries.rbrenamed from lib/docs/filters/rest_framework/entries.rb+2−3
@@ -1,7 +1,6 @@
1module Docs1module Docs
2 class RestFramework2 class DjangoRestFramework
3 class EntriesFilter < Docs::EntriesFilter3 class EntriesFilter < Docs::EntriesFilter
4
5 def get_name4 def get_name
6 name = css('h1').first.content5 name = css('h1').first.content
7 name.slice! 'Tutorial '6 name.slice! 'Tutorial '
@@ -46,7 +45,7 @@ module Docs · 38 unmodified lines
46 next45 next
47 end46 end
48 entries << [node.content, node['id'], local_type]47 entries << [node.content, node['id'], local_type]
49 elsif accepted_headers.include? node.content 48 elsif accepted_headers.include? node.content
50 in_category = true49 in_category = true
51 elsif endings.any? { |word| node.content.ends_with?(word) }50 elsif endings.any? { |word| node.content.ends_with?(word) }
52 entries << [node.content, node['id'], local_type]51 entries << [node.content, node['id'], local_type]
lib/docs/scrapers/mkdocs/django_rest_framework.rbrenamed from lib/docs/scrapers/rest_framework.rb+9−5
@@ -1,8 +1,8 @@
1module Docs1module Docs
2 class RestFramework < Mkdocs2 class DjangoRestFramework < Mkdocs
3 self.name = 'Django REST Framework'3 self.name = 'Django REST Framework'
4 self.release = '3.9.2'4 self.release = '3.9.3'
5 self.slug = 'rest_framework'5 self.slug = 'django_rest_framework'
6 self.base_url = 'https://www.django-rest-framework.org/'6 self.base_url = 'https://www.django-rest-framework.org/'
7 self.root_path = 'index.html'7 self.root_path = 'index.html'
8 self.links = {8 self.links = {
@@ -10,7 +10,7 @@ module Docs · 1 unmodified line
10 code: 'https://github.com/encode/django-rest-framework'10 code: 'https://github.com/encode/django-rest-framework'
11 }11 }
12 12
13 html_filters.push 'rest_framework/clean_html', 'rest_framework/entries'13 html_filters.push 'django_rest_framework/clean_html', 'django_rest_framework/entries'
14 14
15 options[:skip_patterns] = [15 options[:skip_patterns] = [
16 /\Atopics\//,16 /\Atopics\//,
@@ -18,8 +18,12 @@ module Docs · 1 unmodified line
18 ]18 ]
19 19
20 options[:attribution] = <<-HTML20 options[:attribution] = <<-HTML
21 Copyright 2011&ndash;present Encode OSS Ltd<br>21 Copyright 2011&ndash;present Encode OSS Ltd.<br>
22 Licensed under the BSD License.22 Licensed under the BSD License.
23 HTML23 HTML
24
25 def get_latest_version(opts)
26 get_latest_github_release('encode', 'django-rest-framework', opts)
27 end
24 end28 end
25end29end
lib/docs/scrapers/mkdocs/mkdocs.rbrenamed from lib/docs/scrapers/mkdocs.rb+0−0

File renamed without changes.