python.rb 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. options[:only_patterns] = [
  10. # /\Ac-api/,
  11. /\Adistributing/,
  12. # /\Adistutils/,
  13. /\Aextending/,
  14. /\Afaq/,
  15. /\Ahowto/,
  16. /\Aindex.html/,
  17. # /\Ainstall/,
  18. /\Ainstalling/,
  19. /\Alibrary/,
  20. /\Areference/,
  21. /\Atutorial/,
  22. /\Ausing/,
  23. ]
  24. options[:skip] = %w(
  25. library/2to3.html
  26. library/formatter.html
  27. library/intro.html
  28. library/undoc.html
  29. library/unittest.mock-examples.html
  30. library/sunau.html)
  31. options[:attribution] = <<-HTML
  32. &copy; 2001&ndash;2022 Python Software Foundation<br>
  33. Licensed under the PSF License.
  34. HTML
  35. version '3.10' do
  36. self.release = '3.10.4'
  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.4'
  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.6'
  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.9'
  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