History

Update React documentation (15.4.0)

Thibaut Courouble committed 9 years ago

Commit 008e85c1 parent e5356243 files · +29 −62Browse files

Unified · Split

3 files
  1. lib/docs/filters/react/clean_html.rb +1 −1
  2. lib/docs/filters/react/entries.rb +14 −50
  3. lib/docs/scrapers/react.rb +14 −11
lib/docs/filters/react/clean_html.rb+1−1
@@ -8,7 +8,7 @@ module Docs · 7 unmodified lines
88 at_css('h1').content = context[:root_title]
99 end
1010
11− css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github', 'a.hash', '.edit-page-block', 'a.show', 'a.hide').remove
11+ css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github', 'a.hash', '.edit-page-block', 'a.show', 'a.hide', 'hr').remove
1212
1313 css('table h1', 'table h2', 'table h3').each do |node|
1414 table = node
lib/docs/filters/react/entries.rb+14−50
@@ -1,69 +1,33 @@
11 module Docs
22 class React
33 class EntriesFilter < Docs::EntriesFilter
4− API_SLUGS = %w(
5− docs/top-level-api
6− docs/component-api
7− docs/component-specs
8− )
9−
10− REPLACE_TYPES = {
11− 'Quick Start' => 'Guides',
12− 'User Guide' => 'Guides',
13− 'The Basics' => 'Getting Started',
14− 'apis' => 'APIs',
15− 'components' => 'Components'
16− }
17−
184 def get_name
195 at_css('h1').children.select(&:text?).map(&:content).join.strip
206 end
217
228 def get_type
239 link = at_css('.nav-docs-section .active, .toc .active')
24− return 'Miscellaneous' unless link
2510 section = link.ancestors('.nav-docs-section, section').first
2611 type = section.at_css('h3').content.strip
27− type = REPLACE_TYPES[type] || type
28− type += ": #{name}" if type == 'Components'
2912 type
3013 end
3114
3215 def additional_entries
33− if API_SLUGS.include?(slug)
34− css('.inner-content h3, .inner-content h4').map do |node|
35− name = node.content
36− name.remove! %r{[#\(\)]}
37− name.remove! %r{\w+\:}
38− id = node.at_css('.anchor')['name']
39− type = slug.include?('component') ? 'Component' : 'React'
40− [name, id, type]
41− end
42− else
43− entries = []
44−
45− css('.props > .prop > .propTitle', '.props > .prop > .methodTitle').each do |node| # react-native
46− name = node.children.find(&:text?).try(:content)
47− next if name.blank?
48− sep = node.content.include?('static') ? '.' : '#'
49− name.prepend(self.name + sep)
50− name << '()' if node['class'].include?('methodTitle')
51− id = node.at_css('.anchor')['name']
52− entries << [name, id]
16+ css('.inner-content h3 code, .inner-content h4 code').each_with_object([]) do |node, entries|
17+ name = node.content
18+ name.remove! %r{[#\(\)]}
19+ name.remove! %r{\w+\:}
20+ name.strip!
21+ name = 'createFragmentobject' if name.include?('createFragmentobject')
22+ id = node.parent.at_css('.anchor')['name']
23+ type = if slug == 'react-component'
24+ 'Reference: Component'
25+ elsif slug == 'react-api'
26+ 'Reference: React'
27+ else
28+ 'Reference'
5329 end
54−
55− css('.apiIndex a pre').each do |node| # relay
56− next unless node.parent['href'].start_with?('#')
57− id = node.parent['href'].remove('#')
58− name = node.content.strip
59− sep = name.start_with?('static') ? '.' : '#'
60− name.remove! %r{(abstract|static) }
61− name.sub! %r{\(.*\)}, '()'
62− name.prepend(self.name + sep)
63− entries << [name, id]
64− end
65−
66− entries
30+ entries << [name, id, type]
6731 end
6832 end
6933 end
lib/docs/scrapers/react.rb+14−11
@@ -2,9 +2,9 @@ module Docs · 1 unmodified line
22 class React < UrlScraper
33 self.name = 'React'
44 self.type = 'react'
5− self.release = '15.3.0'
6− self.base_url = 'https://facebook.github.io/react/'
7− self.root_path = 'docs/getting-started.html'
5+ self.release = '15.4.0'
6+ self.base_url = 'https://facebook.github.io/react/docs/'
7+ self.root_path = 'hello-world.html'
88 self.links = {
99 home: 'https://facebook.github.io/react/',
1010 code: 'https://github.com/facebook/react'
@@ -14,14 +14,17 @@ module Docs · 3 unmodified lines
1414
1515 options[:root_title] = 'React Documentation'
1616 options[:container] = '.documentationContent'
17− options[:only_patterns] = [/\Adocs\//, /\Atips\//]
18− options[:skip] = %w(
19− docs/
20− docs/videos.html
21− docs/complementary-tools.html
22− docs/examples.html
23− docs/conferences.html
24− tips/introduction.html)
17+
18+ options[:replace_paths] = {
19+ 'top-level-api.html' => 'react-api.html',
20+ 'working-with-the-browser.html' => 'refs-and-the-dom.html',
21+ 'interactivity-and-dynamic-uis.html' => 'state-and-lifecycle.html',
22+ 'more-about-refs.html' => 'refs-and-the-dom.html',
23+ 'advanced-performance.html' => 'optimizing-performance.html',
24+ 'component-api.html' => 'react-component.html',
25+ 'component-specs.html' => 'react-component.html',
26+ 'multiple-components.html' => 'composition-vs-inheritance.html',
27+ }
2528
2629 options[:attribution] = <<-HTML
2730 &copy; 2013&ndash;2016 Facebook Inc.<br>