History

Update React Native documentation (0.38)

Thibaut Courouble committed 9 years ago

Commit 7183d931 parent 2b939853 files · +56 −3Browse files

Unified · Split

3 files
  1. lib/docs/filters/react_native/clean_html.rb +1 −1
  2. lib/docs/filters/react_native/entries.rb +53 −0
  3. lib/docs/scrapers/react_native.rb +2 −2
lib/docs/filters/react_native/clean_html.rb+1−1
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
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
lib/docs/filters/react_native/entries.rb+53−0
@@ -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+2−2
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
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 = {
@@ -11,10 +11,10 @@ module Docs · 1 unmodified line
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