react.rb 1.2 KB

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