python.rb 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. module Docs
  2. class Python < FileScraper
  3. self.type = 'python'
  4. self.root_path = 'library/index.html'
  5. self.links = {
  6. home: 'https://www.python.org/',
  7. code: 'https://github.com/python/cpython'
  8. }
  9. options[:only_patterns] = [/\Alibrary\//]
  10. options[:skip] = %w(
  11. library/2to3.html
  12. library/formatter.html
  13. library/index.html
  14. library/intro.html
  15. library/undoc.html
  16. library/unittest.mock-examples.html
  17. library/sunau.html)
  18. options[:attribution] = <<-HTML
  19. &copy; 2001&ndash;2021 Python Software Foundation<br>
  20. Licensed under the PSF License.
  21. HTML
  22. version '3.10' do
  23. self.release = '3.10.0'
  24. self.base_url = "https://docs.python.org/#{self.version}/"
  25. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  26. end
  27. version '3.9' do
  28. self.release = '3.9.4'
  29. self.base_url = 'https://docs.python.org/3.9/'
  30. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  31. end
  32. version '3.8' do
  33. self.release = '3.8.6'
  34. self.base_url = 'https://docs.python.org/3.8/'
  35. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  36. end
  37. version '3.7' do
  38. self.release = '3.7.9'
  39. self.base_url = 'https://docs.python.org/3.7/'
  40. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  41. end
  42. version '3.6' do
  43. self.release = '3.6.12'
  44. self.base_url = 'https://docs.python.org/3.6/'
  45. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  46. end
  47. version '3.5' do
  48. self.release = '3.5.9'
  49. self.base_url = 'https://docs.python.org/3.5/'
  50. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  51. end
  52. version '2.7' do
  53. self.release = '2.7.17'
  54. self.base_url = 'https://docs.python.org/2.7/'
  55. html_filters.push 'python/entries_v2', 'sphinx/clean_html', 'python/clean_html'
  56. end
  57. def get_latest_version(opts)
  58. doc = fetch_doc('https://docs.python.org/', opts)
  59. doc.at_css('title').content.split(' ')[0]
  60. end
  61. end
  62. end