python.rb 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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[:skip_patterns] = [/whatsnew/]
  10. options[:skip] = %w(
  11. library/2to3.html
  12. library/formatter.html
  13. library/intro.html
  14. library/undoc.html
  15. library/unittest.mock-examples.html
  16. library/sunau.html)
  17. options[:attribution] = <<-HTML
  18. &copy; 2001&ndash;2022 Python Software Foundation<br>
  19. Licensed under the PSF License.
  20. HTML
  21. version '3.11' do
  22. self.release = '3.11.0rc2'
  23. self.base_url = "https://docs.python.org/#{self.version}/"
  24. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  25. end
  26. version '3.10' do
  27. self.release = '3.10.7'
  28. self.base_url = "https://docs.python.org/#{self.version}/"
  29. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  30. end
  31. version '3.9' do
  32. self.release = '3.9.4'
  33. self.base_url = 'https://docs.python.org/3.9/'
  34. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  35. end
  36. version '3.8' do
  37. self.release = '3.8.6'
  38. self.base_url = 'https://docs.python.org/3.8/'
  39. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  40. end
  41. version '3.7' do
  42. self.release = '3.7.9'
  43. self.base_url = 'https://docs.python.org/3.7/'
  44. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  45. end
  46. version '3.6' do
  47. self.release = '3.6.12'
  48. self.base_url = 'https://docs.python.org/3.6/'
  49. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  50. end
  51. version '3.5' do
  52. self.release = '3.5.9'
  53. self.base_url = 'https://docs.python.org/3.5/'
  54. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  55. end
  56. version '2.7' do
  57. self.release = '2.7.17'
  58. self.base_url = 'https://docs.python.org/2.7/'
  59. html_filters.push 'python/entries_v2', 'sphinx/clean_html', 'python/clean_html'
  60. end
  61. def get_latest_version(opts)
  62. doc = fetch_doc('https://docs.python.org/', opts)
  63. doc.at_css('title').content.split(' ')[0]
  64. end
  65. end
  66. end