react.rb 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. module Docs
  2. class React < UrlScraper
  3. self.name = 'React'
  4. self.type = 'simple'
  5. self.links = {
  6. home: 'https://react.dev/',
  7. code: 'https://github.com/facebook/react'
  8. }
  9. version do
  10. self.release = '18.3.1'
  11. self.base_url = 'https://react.dev'
  12. self.initial_paths = %w(/reference/react /learn)
  13. html_filters.push 'react/entries_react_dev', 'react/clean_html_react_dev'
  14. options[:only_patterns] = [/\A\/learn/, /\A\/reference/]
  15. options[:attribution] = <<-HTML
  16. &copy; 2013&ndash;present Facebook Inc.<br>
  17. Licensed under the Creative Commons Attribution 4.0 International Public License.
  18. HTML
  19. end
  20. version '17' do
  21. self.release = '17.0.2'
  22. self.base_url = 'https://17.reactjs.org/docs/'
  23. self.root_path = 'hello-world.html'
  24. html_filters.push 'react/entries', 'react/clean_html'
  25. options[:skip] = %w(
  26. codebase-overview.html
  27. design-principles.html
  28. how-to-contribute.html
  29. implementation-notes.html
  30. )
  31. options[:replace_paths] = {
  32. 'more-about-refs.html' => 'refs-and-the-dom.html',
  33. 'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html',
  34. 'working-with-the-browser.html' => 'refs-and-the-dom.html',
  35. 'top-level-api.html' => 'react-api.html',
  36. }
  37. options[:attribution] = <<-HTML
  38. &copy; 2013&ndash;present Facebook Inc.<br>
  39. Licensed under the Creative Commons Attribution 4.0 International Public License.
  40. HTML
  41. end
  42. def get_latest_version(opts)
  43. doc = fetch_doc('https://react.dev/', opts)
  44. doc.at_css('a[href="/versions"]').content.strip[1..-1]
  45. end
  46. end
  47. end