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