Browse Source

Update and improve React Native documentation (0.10.0)

Thibaut 10 years ago
parent
commit
9cfb3c61e6

+ 3 - 0
assets/stylesheets/pages/_react.scss

@@ -5,4 +5,7 @@
 
   code { @extend %label; }
   blockquote { @extend %note; }
+
+  span.platform { float: right; }
+  span.propType, span.platform { font-weight: normal; }
 }

+ 22 - 10
lib/docs/filters/react/entries.rb

@@ -21,19 +21,31 @@ module Docs
         link = at_css('.nav-docs-section .active')
         section = link.ancestors('.nav-docs-section').first
         type = section.at_css('h3').content.strip
-        REPLACE_TYPES[type] || type
+        type = REPLACE_TYPES[type] || type
+        type += ": #{name}" if type == 'Components'
+        type
       end
 
       def additional_entries
-        return [] unless API_SLUGS.include?(slug)
-
-        css('.inner-content h3, .inner-content h4').map do |node|
-          name = node.content
-          name.remove! %r{[#\(\)]}
-          name.remove! %r{\w+\:}
-          id = node.at_css('.anchor')['name']
-          type = slug.include?('component') ? 'Component' : 'React'
-          [name, id, type]
+        if API_SLUGS.include?(slug)
+          css('.inner-content h3, .inner-content h4').map do |node|
+            name = node.content
+            name.remove! %r{[#\(\)]}
+            name.remove! %r{\w+\:}
+            id = node.at_css('.anchor')['name']
+            type = slug.include?('component') ? 'Component' : 'React'
+            [name, id, type]
+          end
+        else
+          css('.props > .prop > .propTitle').each_with_object([]) do |node, entries|
+            name = node.children.find(&:text?).try(:content)
+            next if name.blank?
+            sep = node.content.include?('static') ? '.' : '#'
+            name.prepend(self.name + sep)
+            name << '()' if node.css('.propType').last.content.start_with?('(')
+            id = node.at_css('.anchor')['name']
+            entries << [name, id]
+          end
         end
       end
     end

+ 1 - 1
lib/docs/scrapers/react_native.rb

@@ -3,7 +3,7 @@ module Docs
     self.name = 'React Native'
     self.slug = 'react_native'
     self.type = 'react'
-    self.version = '0.8.0'
+    self.version = '0.10.0'
     self.base_url = 'https://facebook.github.io/react-native/docs/'
     self.root_path = 'getting-started.html'
     self.links = {