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 (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 @@
11 module Docs
2− class RestFramework
2+ class DjangoRestFramework
33 class CleanHtmlFilter < Docs::Filter
44 def call
55 css('hr').remove
6−
76 css('.badges').remove
87
98 css('pre').attr('data-language', 'python')
109
11− css('h1').attr('style', nil)
10+ css('h1').remove_attribute('style')
11+ css('.promo a').remove_attribute('style')
1212
1313 # Translate source files links to DevDocs links
1414 links = Nokogiri::XML::Node.new('p', doc)
@@ -20,6 +20,7 @@ module Docs · 5 unmodified lines
2020 node['class'] = '_links-link'
2121 links.add_child(node)
2222 end
23+
2324 doc.add_child(links)
2425
2526 doc
lib/docs/filters/django_rest_framework/entries.rbrenamed from lib/docs/filters/rest_framework/entries.rb+2−3
@@ -1,7 +1,6 @@
11 module Docs
2− class RestFramework
2+ class DjangoRestFramework
33 class EntriesFilter < Docs::EntriesFilter
4−
54 def get_name
65 name = css('h1').first.content
76 name.slice! 'Tutorial '
@@ -46,7 +45,7 @@ module Docs · 38 unmodified lines
4645 next
4746 end
4847 entries << [node.content, node['id'], local_type]
49− elsif accepted_headers.include? node.content
48+ elsif accepted_headers.include? node.content
5049 in_category = true
5150 elsif endings.any? { |word| node.content.ends_with?(word) }
5251 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 @@
11 module Docs
2− class RestFramework < Mkdocs
2+ class DjangoRestFramework < Mkdocs
33 self.name = 'Django REST Framework'
4− self.release = '3.9.2'
5− self.slug = 'rest_framework'
4+ self.release = '3.9.3'
5+ self.slug = 'django_rest_framework'
66 self.base_url = 'https://www.django-rest-framework.org/'
77 self.root_path = 'index.html'
88 self.links = {
@@ -10,7 +10,7 @@ module Docs · 1 unmodified line
1010 code: 'https://github.com/encode/django-rest-framework'
1111 }
1212
13− html_filters.push 'rest_framework/clean_html', 'rest_framework/entries'
13+ html_filters.push 'django_rest_framework/clean_html', 'django_rest_framework/entries'
1414
1515 options[:skip_patterns] = [
1616 /\Atopics\//,
@@ -18,8 +18,12 @@ module Docs · 1 unmodified line
1818 ]
1919
2020 options[:attribution] = <<-HTML
21− Copyright 2011&ndash;present Encode OSS Ltd<br>
21+ Copyright 2011&ndash;present Encode OSS Ltd.<br>
2222 Licensed under the BSD License.
2323 HTML
24+
25+ def get_latest_version(opts)
26+ get_latest_github_release('encode', 'django-rest-framework', opts)
27+ end
2428 end
2529 end
lib/docs/scrapers/mkdocs/mkdocs.rbrenamed from lib/docs/scrapers/mkdocs.rb+0−0

File renamed without changes.