1
0

python.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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.9' do
  23. self.release = '3.9.4'
  24. self.base_url = 'https://docs.python.org/3.9/'
  25. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  26. end
  27. version '3.8' do
  28. self.release = '3.8.6'
  29. self.base_url = 'https://docs.python.org/3.8/'
  30. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  31. end
  32. version '3.7' do
  33. self.release = '3.7.9'
  34. self.base_url = 'https://docs.python.org/3.7/'
  35. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  36. end
  37. version '3.6' do
  38. self.release = '3.6.12'
  39. self.base_url = 'https://docs.python.org/3.6/'
  40. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  41. end
  42. version '3.5' do
  43. self.release = '3.5.9'
  44. self.base_url = 'https://docs.python.org/3.5/'
  45. html_filters.push 'python/entries_v3', 'sphinx/clean_html', 'python/clean_html'
  46. end
  47. version '2.7' do
  48. self.release = '2.7.17'
  49. self.base_url = 'https://docs.python.org/2.7/'
  50. html_filters.push 'python/entries_v2', 'sphinx/clean_html', 'python/clean_html'
  51. end
  52. def get_latest_version(opts)
  53. doc = fetch_doc('https://docs.python.org/', opts)
  54. doc.at_css('title').content.split(' ')[0]
  55. end
  56. end
  57. end