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
3 class CleanHtmlFilter < Filter3 class CleanHtmlFilter < Filter
4 def call4 def call
5 if root_page?5 if root_page?
6 css('#unsupported + div + center', '#unsupported + div', '#unsupported', '.toggler', 'center > img').remove6 css('h1 ~ *').remove
7 end7 end
8 8
9 css('center > .button', 'p:contains("short survey")', 'iframe', '.embedded-simulator').remove9 css('center > .button', 'p:contains("short survey")', 'iframe', '.embedded-simulator').remove
lib/docs/filters/react_native/entries.rb+53−0
@@ -0,0 +1,53 @@
1module 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
53end
lib/docs/scrapers/react_native.rb+2−2
@@ -3,7 +3,7 @@ module Docs · 2 unmodified lines
3 self.name = 'React Native'3 self.name = 'React Native'
4 self.slug = 'react_native'4 self.slug = 'react_native'
5 self.type = 'react'5 self.type = 'react'
6 self.release = '0.37'6 self.release = '0.38'
7 self.base_url = 'https://facebook.github.io/react-native/docs/'7 self.base_url = 'https://facebook.github.io/react-native/docs/'
8 self.root_path = 'getting-started.html'8 self.root_path = 'getting-started.html'
9 self.links = {9 self.links = {
@@ -11,10 +11,10 @@ module Docs · 1 unmodified line
11 code: 'https://github.com/facebook/react-native'11 code: 'https://github.com/facebook/react-native'
12 }12 }
13 13
14 html_filters.replace 'react/entries', 'react_native/entries'
14 html_filters.push 'react_native/clean_html'15 html_filters.push 'react_native/clean_html'
15 16
16 options[:root_title] = 'React Native Documentation'17 options[:root_title] = 'React Native Documentation'
17 options[:only_patterns] = nil
18 options[:skip_patterns] = [/\Asample\-/]18 options[:skip_patterns] = [/\Asample\-/]
19 options[:skip] = %w(19 options[:skip] = %w(
20 videos.html20 videos.html