Skip to content

Commit 7183d93

Browse files
committed
Update React Native documentation (0.38)
1 parent 2b93985 commit 7183d93

3 files changed

Lines changed: 56 additions & 3 deletions

File tree

lib/docs/filters/react_native/clean_html.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class ReactNative
33
class CleanHtmlFilter < Filter
44
def call
55
if root_page?
6-
css('#unsupported + div + center', '#unsupported + div', '#unsupported', '.toggler', 'center > img').remove
6+
css('h1 ~ *').remove
77
end
88

99
css('center > .button', 'p:contains("short survey")', 'iframe', '.embedded-simulator').remove
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
module Docs
2+
class ReactNative
3+
class EntriesFilter < Docs::EntriesFilter
4+
5+
REPLACE_TYPES = {
6+
'The Basics' => 'Getting Started',
7+
'apis' => 'APIs',
8+
'components' => 'Components'
9+
}
10+
11+
def get_name
12+
at_css('h1').children.select(&:text?).map(&:content).join.strip
13+
end
14+
15+
def get_type
16+
link = at_css('.nav-docs-section .active, .toc .active')
17+
return 'Miscellaneous' unless link
18+
section = link.ancestors('.nav-docs-section, section').first
19+
type = section.at_css('h3').content.strip
20+
type = REPLACE_TYPES[type] || type
21+
type += ": #{name}" if type == 'Components'
22+
type
23+
end
24+
25+
def additional_entries
26+
entries = []
27+
28+
css('.props > .prop > .propTitle', '.props > .prop > .methodTitle').each do |node| # react-native
29+
name = node.children.find(&:text?).try(:content)
30+
next if name.blank?
31+
sep = node.content.include?('static') ? '.' : '#'
32+
name.prepend(self.name + sep)
33+
name << '()' if node['class'].include?('methodTitle')
34+
id = node.at_css('.anchor')['name']
35+
entries << [name, id]
36+
end
37+
38+
css('.apiIndex a pre').each do |node| # relay
39+
next unless node.parent['href'].start_with?('#')
40+
id = node.parent['href'].remove('#')
41+
name = node.content.strip
42+
sep = name.start_with?('static') ? '.' : '#'
43+
name.remove! %r{(abstract|static) }
44+
name.sub! %r{\(.*\)}, '()'
45+
name.prepend(self.name + sep)
46+
entries << [name, id]
47+
end
48+
49+
entries
50+
end
51+
end
52+
end
53+
end

lib/docs/scrapers/react_native.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@ class ReactNative < React
33
self.name = 'React Native'
44
self.slug = 'react_native'
55
self.type = 'react'
6-
self.release = '0.37'
6+
self.release = '0.38'
77
self.base_url = 'https://facebook.github.io/react-native/docs/'
88
self.root_path = 'getting-started.html'
99
self.links = {
1010
home: 'https://facebook.github.io/react-native/',
1111
code: 'https://github.com/facebook/react-native'
1212
}
1313

14+
html_filters.replace 'react/entries', 'react_native/entries'
1415
html_filters.push 'react_native/clean_html'
1516

1617
options[:root_title] = 'React Native Documentation'
17-
options[:only_patterns] = nil
1818
options[:skip_patterns] = [/\Asample\-/]
1919
options[:skip] = %w(
2020
videos.html

0 commit comments

Comments
 (0)