godot.rb 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. module Docs
  2. class Godot < UrlScraper
  3. self.type = 'sphinx_simple'
  4. self.links = {
  5. home: 'https://godotengine.org/',
  6. code: 'https://github.com/godotengine/godot'
  7. }
  8. # godot docs since 3.5 don't link everything from the index.
  9. self.initial_paths = %w[
  10. getting_started/introduction/index.html
  11. getting_started/step_by_step/index.html
  12. classes/index.html
  13. ]
  14. options[:container] = '.document > [itemprop="articleBody"]'
  15. options[:download_images] = false
  16. options[:only_patterns] = [%r{\Agetting_started/}, %r{\Aclasses/}]
  17. options[:attribution] = <<-HTML
  18. &copy; 2014&ndash;present Juan Linietsky, Ariel Manzur and the Godot community<br>
  19. Licensed under the Creative Commons Attribution Unported License v3.0.
  20. HTML
  21. version '4.2' do
  22. self.release = '4.2.2'
  23. self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
  24. html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
  25. end
  26. version '3.5' do
  27. self.release = '3.5.3'
  28. self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
  29. # godot 3.5 upstream docs are formatted like godot4
  30. html_filters.push 'godot/entries', 'godot/clean_html', 'sphinx/clean_html'
  31. end
  32. version '3.4' do
  33. self.release = '3.4.5'
  34. self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
  35. options[:container] = '.document > [itemprop="articleBody"] > section[id]'
  36. html_filters.push 'godot/entries_v3', 'godot/clean_html_v3', 'sphinx/clean_html'
  37. end
  38. version '3.3' do
  39. self.release = '3.3.0'
  40. self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
  41. self.initial_paths = %w[/index.html]
  42. options[:only_patterns] = [%r{\Aclasses/}]
  43. options[:container] = '.document .section'
  44. html_filters.push 'godot/entries_v3', 'godot/clean_html_v3', 'sphinx/clean_html'
  45. end
  46. version '3.2' do
  47. self.release = '3.2.3'
  48. self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
  49. self.initial_paths = %w[/index.html]
  50. options[:only_patterns] = [%r{\Aclasses/}]
  51. options[:container] = '.document .section'
  52. html_filters.push 'godot/entries_v3', 'godot/clean_html_v3', 'sphinx/clean_html'
  53. end
  54. version '2.1' do
  55. self.release = '2.1.6'
  56. self.base_url = "https://docs.godotengine.org/en/#{self.version}/"
  57. self.initial_paths = %w[/index.html]
  58. options[:skip] = %w(classes/class_@global\ scope.html)
  59. options[:only_patterns] = [%r{\Alearning/}, %r{\Aclasses/}]
  60. options[:container] = '.document .section'
  61. html_filters.push 'godot/entries_v2', 'godot/clean_html_v2', 'sphinx/clean_html'
  62. end
  63. def get_latest_version(opts)
  64. get_latest_github_release('godotengine', 'godot', opts).split('-')[0]
  65. end
  66. end
  67. end