Browse Source

Separate React 17

Gergely Gombos 1 year ago
parent
commit
7c5132afec
1 changed files with 25 additions and 22 deletions
  1. 25 22
      lib/docs/scrapers/react.rb

+ 25 - 22
lib/docs/scrapers/react.rb

@@ -2,37 +2,40 @@ module Docs
   class React < UrlScraper
     self.name = 'React'
     self.type = 'simple'
-    self.release = '18.2.0'
-    self.base_url = 'https://reactjs.org/docs/'
-    self.root_path = 'hello-world.html'
     self.links = {
-      home: 'https://reactjs.org/',
+      home: 'https://react.dev/',
       code: 'https://github.com/facebook/react'
     }
 
-    html_filters.push 'react/entries', 'react/clean_html'
+    version '17' do
+      self.release = '17.0.2'
+      self.base_url = 'https://17.reactjs.org/docs/'
+      self.root_path = 'hello-world.html'
+      html_filters.push 'react/entries', 'react/clean_html'
 
-    options[:skip] = %w(
-      codebase-overview.html
-      design-principles.html
-      how-to-contribute.html
-      implementation-notes.html
-    )
+      options[:skip] = %w(
+        codebase-overview.html
+        design-principles.html
+        how-to-contribute.html
+        implementation-notes.html
+      )
 
-    options[:replace_paths] = {
-      'more-about-refs.html' => 'refs-and-the-dom.html',
-      'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html',
-      'working-with-the-browser.html' => 'refs-and-the-dom.html',
-      'top-level-api.html' => 'react-api.html',
-    }
+      options[:replace_paths] = {
+        'more-about-refs.html' => 'refs-and-the-dom.html',
+        'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html',
+        'working-with-the-browser.html' => 'refs-and-the-dom.html',
+        'top-level-api.html' => 'react-api.html',
+      }
+
+      options[:attribution] = <<-HTML
+        &copy; 2013&ndash;present Facebook Inc.<br>
+        Licensed under the Creative Commons Attribution 4.0 International Public License.
+      HTML
+    end
 
-    options[:attribution] = <<-HTML
-      &copy; 2013&ndash;present Facebook Inc.<br>
-      Licensed under the Creative Commons Attribution 4.0 International Public License.
-    HTML
 
     def get_latest_version(opts)
-      doc = fetch_doc('https://reactjs.org/docs/getting-started.html', opts)
+      doc = fetch_doc('https://react.dev/', opts)
       doc.at_css('a[href="/versions"]').content.strip[1..-1]
     end
   end