react.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. # TODO add /learn
  12. self.base_url = 'https://react.dev/reference'
  13. html_filters.push 'react/entries_react_dev', 'react/clean_html_react_dev'
  14. options[:attribution] = <<-HTML
  15. &copy; 2013&ndash;present Facebook Inc.<br>
  16. Licensed under the Creative Commons Attribution 4.0 International Public License.
  17. HTML
  18. end
  19. version '17' do
  20. self.release = '17.0.2'
  21. self.base_url = 'https://17.reactjs.org/docs/'
  22. self.root_path = 'hello-world.html'
  23. html_filters.push 'react/entries', 'react/clean_html'
  24. options[:skip] = %w(
  25. codebase-overview.html
  26. design-principles.html
  27. how-to-contribute.html
  28. implementation-notes.html
  29. )
  30. options[:replace_paths] = {
  31. 'more-about-refs.html' => 'refs-and-the-dom.html',
  32. 'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html',
  33. 'working-with-the-browser.html' => 'refs-and-the-dom.html',
  34. 'top-level-api.html' => 'react-api.html',
  35. }
  36. options[:attribution] = <<-HTML
  37. &copy; 2013&ndash;present Facebook Inc.<br>
  38. Licensed under the Creative Commons Attribution 4.0 International Public License.
  39. HTML
  40. end
  41. def get_latest_version(opts)
  42. doc = fetch_doc('https://react.dev/', opts)
  43. doc.at_css('a[href="/versions"]').content.strip[1..-1]
  44. end
  45. end
  46. end