[devdocsgjs/main: 125/239] Update React Native documentation (0.66)




commit 79ffe3fd6a86729f448a1c1a9403e09674206961
Author: Simon Legner <Simon Legner gmail com>
Date:   Wed Jan 12 21:55:55 2022 +0100

    Update React Native documentation (0.66)

 .../javascripts/templates/pages/about_tmpl.coffee  |  2 +-
 assets/stylesheets/pages/_react_native.scss        | 11 ++++++++
 lib/docs/filters/react_native/clean_html.rb        | 32 ++++++++++++----------
 lib/docs/filters/react_native/entries.rb           | 24 ++++++----------
 lib/docs/scrapers/react_native.rb                  | 13 +++++----
 public/icons/docs/react_native/SOURCE              |  2 +-
 6 files changed, 46 insertions(+), 38 deletions(-)
---
diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee 
b/assets/javascripts/templates/pages/about_tmpl.coffee
index a9a62681..d4d352aa 100644
--- a/assets/javascripts/templates/pages/about_tmpl.coffee
+++ b/assets/javascripts/templates/pages/about_tmpl.coffee
@@ -724,7 +724,7 @@ credits = [
     'https://raw.githubusercontent.com/ramda/ramda/master/LICENSE.txt'
   ], [
     'React, React Native, Flow, Relay',
-    '2013-present Facebook Inc.',
+    'Facebook Inc. and its affiliates',
     'MIT',
     'https://raw.githubusercontent.com/facebook/react/master/LICENSE'
   ], [
diff --git a/assets/stylesheets/pages/_react_native.scss b/assets/stylesheets/pages/_react_native.scss
index 1345a35f..824c9d19 100644
--- a/assets/stylesheets/pages/_react_native.scss
+++ b/assets/stylesheets/pages/_react_native.scss
@@ -6,4 +6,15 @@
 
   span.platform { float: right; }
   span.propType, span.platform { font-weight: normal; }
+
+  .label {
+    display:inline-block;
+    font-size:.85rem;
+   }
+   .label::before {
+     content: "[";
+   }
+   .label::after {
+     content: "]";
+   }
 }
diff --git a/lib/docs/filters/react_native/clean_html.rb b/lib/docs/filters/react_native/clean_html.rb
index ecc233be..5450bfa7 100644
--- a/lib/docs/filters/react_native/clean_html.rb
+++ b/lib/docs/filters/react_native/clean_html.rb
@@ -2,13 +2,30 @@ module Docs
   class ReactNative
     class CleanHtmlFilter < Filter
       def call
-        @doc = at_css('.post')
+        @doc = at_css('main .col .markdown')
 
         if root_page?
           at_css('h1').content = 'React Native Documentation'
           css('h1 ~ *').remove
         end
 
+        css('header').each do |node|
+          node.before(node.children).remove
+        end
+
+        css('.content-banner-img').remove
+        css('.anchor').remove_attribute('class')
+        css('button[aria-label="Copy code to clipboard"]').remove
+        css('h2#example').remove
+
+        css('pre').each do |node|
+          node.content = node.css('.token-line').map(&:content).join("\n")
+          node.remove_attribute('class')
+          node['data-language'] = 'jsx'
+        end
+
+        #
+
         css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github', 'a.hash', '.edit-page-block', 
'a.show', 'a.hide', 'hr').remove
 
         css('table h1', 'table h2', 'table h3').each do |node|
@@ -21,23 +38,10 @@ module Docs
           node.parent['id'] ||= node['name'] || node['id']
         end
 
-        css('.highlight').each do |node|
-          node.name = 'pre'
-          node.css('.gutter').remove
-          node['data-language'] = node.at_css('[data-lang]').try(:[], 'data-lang') || 'js'
-          node.content = node.content.strip
-        end
-
         css('table.highlighttable').each do |node|
           node.replace(node.at_css('pre.highlight'))
         end
 
-        css('.prism').each do |node|
-          node.name = 'pre'
-          node['data-language'] = node['class'][/(?<=language\-)(\w+)/]
-          node.content = node.content
-        end
-
         css('pre > code.hljs').each do |node|
           node.parent['data-language'] = 'jsx'
           node.before(node.children).remove
diff --git a/lib/docs/filters/react_native/entries.rb b/lib/docs/filters/react_native/entries.rb
index 71a55ece..a3a9c793 100644
--- a/lib/docs/filters/react_native/entries.rb
+++ b/lib/docs/filters/react_native/entries.rb
@@ -1,33 +1,25 @@
 module Docs
   class ReactNative
     class EntriesFilter < Docs::EntriesFilter
-      REPLACE_TYPES = {
-        'The Basics' => 'Getting Started',
-        'apis' => 'APIs',
-        'components' => 'Components'
-      }
-
       def get_name
         at_css('h1').children.select(&:text?).map(&:content).join.strip
       end
 
       def get_type
-        link = at_css('.navListItemActive')
-        return 'Miscellaneous' unless link
-        section = link.ancestors('.navGroup').first
-        type = section.at_css('h3').content.strip
-        type = REPLACE_TYPES[type] || type
-        type += ": #{name}" if type == 'Components'
-        type
+        type = at_css('.navbar__link--active')
+        return 'Miscellaneous' unless type
+        type.content.strip
       end
 
       def additional_entries
-        css('.mainContainer h3').each_with_object [] do |node, entries|
-          subname = node.text
+        css('main .col .markdown h3').each_with_object [] do |node, entries|
+          code = node.at_css('code')
+          next unless code
+          subname = code.text
           next if subname.blank? || node.css('code').empty?
           sep = subname.include?('()') ? '.' : '#'
           subname.prepend(name + sep)
-          id = node.at_css('.anchor')['id']
+          id = node['id']
           entries << [subname, id]
         end
       end
diff --git a/lib/docs/scrapers/react_native.rb b/lib/docs/scrapers/react_native.rb
index d00e55c2..39249b4e 100644
--- a/lib/docs/scrapers/react_native.rb
+++ b/lib/docs/scrapers/react_native.rb
@@ -1,19 +1,19 @@
 module Docs
   class ReactNative < UrlScraper
+    self.name = 'React Native'
     self.slug = 'react_native'
     self.type = 'react_native'
-    self.release = '0.56'
-    self.base_url = 'https://facebook.github.io/react-native/docs/'
+    self.release = '0.66'
+    self.base_url = 'https://reactnative.dev/docs/'
     self.root_path = 'getting-started.html'
     self.links = {
-      home: 'https://facebook.github.io/react-native/',
+      home: 'https://reactnative.dev/',
       code: 'https://github.com/facebook/react-native'
     }
 
     html_filters.push 'react_native/entries', 'react_native/clean_html'
 
-    options[:container] = '.docMainWrapper'
-    options[:skip_patterns] = [/\Asample\-/]
+    options[:skip_patterns] = [/\Asample\-/, /\A0\./, /\Anext\b/]
     options[:skip] = %w(
       videos.html
       transforms.html
@@ -26,8 +26,9 @@ module Docs
       url
     }
 
+    # https://github.com/facebook/react-native-website/blob/main/LICENSE-docs
     options[:attribution] = <<-HTML
-      &copy; 2015&ndash;2018 Facebook Inc.<br>
+      &copy; 2022 Facebook Inc.<br>
       Licensed under the Creative Commons Attribution 4.0 International Public License.
     HTML
 
diff --git a/public/icons/docs/react_native/SOURCE b/public/icons/docs/react_native/SOURCE
index c1d5f7fb..65f9e914 100644
--- a/public/icons/docs/react_native/SOURCE
+++ b/public/icons/docs/react_native/SOURCE
@@ -1 +1 @@
-https://github.com/facebook/react-native/blob/gh-pages/img/favicon.png
+https://github.com/facebook/react-native-website/blob/main/website/static/docs/assets/favicon.png


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]