python.rb 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. module Docs
  2. class Python < UrlScraper
  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;2025 Python Software Foundation<br>
  23. Licensed under the PSF License.
  24. HTML
  25. version '3.13' do
  26. self.release = '3.13.5'
  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.12' do
  31. self.release = '3.12.9'
  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.11' do
  36. self.release = '3.11.11'
  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.10' do
  41. self.release = '3.10.13'
  42. self.base_url = "https://docs.python.org/#{self.version}/"
  43. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  44. end
  45. version '3.9' do
  46. self.release = '3.9.14'
  47. self.base_url = 'https://docs.python.org/3.9/'
  48. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  49. end
  50. version '3.8' do
  51. self.release = '3.8.14'
  52. self.base_url = 'https://docs.python.org/3.8/'
  53. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  54. end
  55. version '3.7' do
  56. self.release = '3.7.14'
  57. self.base_url = 'https://docs.python.org/3.7/'
  58. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  59. end
  60. version '3.6' do
  61. self.release = '3.6.12'
  62. self.base_url = 'https://docs.python.org/3.6/'
  63. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  64. end
  65. version '3.5' do
  66. self.release = '3.5.9'
  67. self.base_url = 'https://docs.python.org/3.5/'
  68. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  69. end
  70. version '2.7' do
  71. self.release = '2.7.17'
  72. self.base_url = 'https://docs.python.org/2.7/'
  73. html_filters.push 'python/entries_v2', 'sphinx/clean_html', 'python/clean_html'
  74. end
  75. def get_latest_version(opts)
  76. doc = fetch_doc('https://docs.python.org/', opts)
  77. doc.at_css('title').content.split(' ')[0]
  78. end
  79. end
  80. end