django.rb 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. module Docs
  2. class Django < FileScraper
  3. self.name = 'Django'
  4. self.type = 'sphinx'
  5. self.root_path = 'index.html'
  6. self.links = {
  7. home: 'https://www.djangoproject.com/',
  8. code: 'https://github.com/django/django'
  9. }
  10. html_filters.push 'django/entries', 'sphinx/clean_html', 'django/clean_html'
  11. text_filters.push 'django/fix_urls'
  12. options[:container] = '#bd'
  13. options[:skip] = %w(
  14. contents.html
  15. genindex.html
  16. py-modindex.html
  17. glossary.html
  18. search.html
  19. intro/whatsnext.html)
  20. options[:skip_patterns] = [
  21. /\Afaq\//,
  22. /\Ainternals\//,
  23. /\Amisc\//,
  24. /\Areleases\//,
  25. /\A_/,
  26. /flattened\-index\.html/]
  27. options[:attribution] = <<-HTML
  28. &copy; Django Software Foundation and individual contributors<br>
  29. Licensed under the BSD License.
  30. HTML
  31. version '2.2' do
  32. self.release = '2.2.4'
  33. self.base_url = 'https://docs.djangoproject.com/en/2.2/'
  34. end
  35. version '2.1' do
  36. self.release = '2.1.11'
  37. self.base_url = 'https://docs.djangoproject.com/en/2.1/'
  38. end
  39. version '2.0' do
  40. self.release = '2.0.13'
  41. self.base_url = 'https://docs.djangoproject.com/en/2.0/'
  42. end
  43. version '1.11' do
  44. self.release = '1.11.23'
  45. self.base_url = 'https://docs.djangoproject.com/en/1.11/'
  46. end
  47. version '1.10' do
  48. self.release = '1.10.8'
  49. self.base_url = 'https://docs.djangoproject.com/en/1.10/'
  50. end
  51. version '1.9' do
  52. self.release = '1.9.13'
  53. self.base_url = 'https://docs.djangoproject.com/en/1.9/'
  54. end
  55. version '1.8' do
  56. self.release = '1.8.18'
  57. self.base_url = 'https://docs.djangoproject.com/en/1.8/'
  58. end
  59. def get_latest_version(opts)
  60. doc = fetch_doc('https://docs.djangoproject.com/', opts)
  61. doc.at_css('#doc-versions > li.current > span > strong').content
  62. end
  63. end
  64. end