react.rb 1.7 KB

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