python.rb 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. module Docs
  2. class Python < FileScraper
  3. self.type = 'python'
  4. self.root_path = 'index.html'
  5. self.links = {
  6. home: 'https://www.python.org/',
  7. code: 'https://github.com/python/cpython'
  8. }
  9. # bypass the clean_text filter as it removes empty span with ids
  10. options[:clean_text] = false
  11. # bypass sphinx modifying empty ids
  12. options[:sphinx_keep_empty_ids] = true
  13. options[:skip_patterns] = [/whatsnew/]
  14. options[:skip] = %w(
  15. library/2to3.html
  16. library/formatter.html
  17. library/intro.html
  18. library/undoc.html
  19. library/unittest.mock-examples.html
  20. library/sunau.html)
  21. options[:attribution] = <<-HTML
  22. &copy; 2001&ndash;2023 Python Software Foundation<br>
  23. Licensed under the PSF License.
  24. HTML
  25. version '3.12' do
  26. self.release = '3.12.1'
  27. self.base_url = "https://docs.python.org/#{self.version}/"
  28. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  29. end
  30. version '3.11' do
  31. self.release = '3.11.7'
  32. self.base_url = "https://docs.python.org/#{self.version}/"
  33. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  34. end
  35. version '3.10' do
  36. self.release = '3.10.13'
  37. self.base_url = "https://docs.python.org/#{self.version}/"
  38. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  39. end
  40. version '3.9' do
  41. self.release = '3.9.14'
  42. self.base_url = 'https://docs.python.org/3.9/'
  43. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  44. end
  45. version '3.8' do
  46. self.release = '3.8.14'
  47. self.base_url = 'https://docs.python.org/3.8/'
  48. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  49. end
  50. version '3.7' do
  51. self.release = '3.7.14'
  52. self.base_url = 'https://docs.python.org/3.7/'
  53. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  54. end
  55. version '3.6' do
  56. self.release = '3.6.12'
  57. self.base_url = 'https://docs.python.org/3.6/'
  58. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  59. end
  60. version '3.5' do
  61. self.release = '3.5.9'
  62. self.base_url = 'https://docs.python.org/3.5/'
  63. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  64. end
  65. version '2.7' do
  66. self.release = '2.7.17'
  67. self.base_url = 'https://docs.python.org/2.7/'
  68. html_filters.push 'python/entries_v2', 'sphinx/clean_html', 'python/clean_html'
  69. end
  70. def get_latest_version(opts)
  71. doc = fetch_doc('https://docs.python.org/', opts)
  72. doc.at_css('title').content.split(' ')[0]
  73. end
  74. end
  75. end