Update React Native documentation (0.66)

pull/1693/head
Simon Legner 3 years ago
parent 215c57e07f
commit 79ffe3fd6a

@ -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'
], [

@ -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: "]";
}
}

@ -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

@ -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

@ -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

@ -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

Loading…
Cancel
Save