react.rb 1.2 KB

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