Browse Source

Add React Native documentation

Thibaut 10 years ago
parent
commit
eabcb6179a

BIN
assets/images/icons.png


BIN
assets/images/icons@2x.png


+ 3 - 0
assets/javascripts/news.json

@@ -1,5 +1,8 @@
 [
   [
+    "2015-08-09",
+    "New documentation: <a href=\"/react_native/\">React Native</a>"
+  ], [
     "2015-08-03",
     "Added an icon in the sidebar to constrain the width of the UI (visible when applicable)."
   ], [

+ 1 - 1
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -310,7 +310,7 @@ credits = [
     'MIT',
     'https://raw.githubusercontent.com/kriskowal/q/v1/LICENSE'
   ], [
-    'React',
+    'React, React Native',
     '2013-2015 Facebook Inc.',
     'CC BY',
     'https://raw.githubusercontent.com/facebook/react/master/LICENSE-docs'

+ 2 - 1
assets/stylesheets/global/_icons.scss

@@ -4,7 +4,7 @@
   width: 1rem;
   height: 1rem;
   background-image: image-url('icons.png');
-  background-size: 10rem 9rem;
+  background-size: 10rem 10rem;
 }
 
 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -111,3 +111,4 @@
 %icon-contract              { background-position: -7rem -8rem; }
 %icon-expand-white          { background-position: -8rem -8rem; }
 %icon-contract-white        { background-position: -9rem -8rem; }
+._icon-react_native:before  { background-position: 0 -9rem; }

+ 1 - 1
assets/stylesheets/pages/_react.scss

@@ -1,7 +1,7 @@
 ._react {
   > h2 { @extend %block-heading; }
   > h3 { @extend %block-label, %label-blue; }
-  > h4 { font-size: 1em; }
+  > h4 { @extend %block-label; }
 
   code { @extend %label; }
   blockquote { @extend %note; }

+ 15 - 2
lib/docs/filters/react/clean_html.rb

@@ -5,10 +5,10 @@ module Docs
         @doc = at_css('.inner-content')
 
         if root_page?
-          at_css('h1').content = 'React Documentation'
+          at_css('h1').content = context[:root_title]
         end
 
-        css('.docs-prevnext', '.hash-link', '.edit-page-link').remove
+        css('.docs-prevnext', '.hash-link', '.edit-page-link', '.edit-github').remove
 
         css('a.anchor').each do |node|
           node.parent['id'] = node['name']
@@ -20,10 +20,23 @@ module Docs
           node.content = node.content
         end
 
+        css('.prism').each do |node|
+          node.name = 'pre'
+          node['data-lang'] = node['class'][/(?<=language\-)(\w+)/]
+          node.content = node.content
+        end
+
         css('blockquote > p:first-child').each do |node|
           node.remove if node.content.strip == 'Note:'
         end
 
+        css('h3#props', 'h3#methods').each { |node| node.name = 'h2' }
+        css('h4.propTitle').each { |node| node.name = 'h3' }
+
+        css('> div > div', '> div', 'div > span', '.props', '.prop').each do |node|
+          node.before(node.children).remove
+        end
+
         doc
       end
     end

+ 8 - 1
lib/docs/filters/react/entries.rb

@@ -7,6 +7,12 @@ module Docs
         docs/component-specs
       )
 
+      REPLACE_TYPES = {
+        'Quick Start' => 'Guides',
+        'apis' => 'APIs',
+        'components' => 'Components'
+      }
+
       def get_name
         at_css('h1').child.content
       end
@@ -14,7 +20,8 @@ module Docs
       def get_type
         link = at_css('.nav-docs-section .active')
         section = link.ancestors('.nav-docs-section').first
-        section.at_css('h3').content
+        type = section.at_css('h3').content.strip
+        REPLACE_TYPES[type] || type
       end
 
       def additional_entries

+ 1 - 0
lib/docs/scrapers/react.rb

@@ -12,6 +12,7 @@ module Docs
 
     html_filters.push 'react/entries', 'react/clean_html'
 
+    options[:root_title] = 'React Documentation'
     options[:container] = '.documentationContent'
     options[:only_patterns] = [/\Adocs\//, /\Atips\//]
     options[:skip] = %w(

+ 26 - 0
lib/docs/scrapers/react_native.rb

@@ -0,0 +1,26 @@
+module Docs
+  class ReactNative < React
+    self.name = 'React Native'
+    self.slug = 'react_native'
+    self.type = 'react'
+    self.version = '0.8.0'
+    self.base_url = 'https://facebook.github.io/react-native/docs/'
+    self.root_path = 'getting-started.html'
+    self.links = {
+      home: 'https://facebook.github.io/react-native/',
+      code: 'https://github.com/facebook/react-native'
+    }
+
+    options[:root_title] = 'React Native Documentation'
+    options[:only_patterns] = nil
+    options[:skip] = %w(
+      videos.html
+      transforms.html
+      troubleshooting.html)
+
+    options[:attribution] = <<-HTML
+      &copy; 2015 Facebook Inc.<br>
+      Licensed under the Creative Commons Attribution 4.0 International Public License.
+    HTML
+  end
+end

BIN
public/icons/docs/react_native/16.png


BIN
public/icons/docs/react_native/16@2x.png


+ 1 - 0
public/icons/docs/react_native/SOURCE

@@ -0,0 +1 @@
+https://github.com/facebook/react-native/blob/gh-pages/img/favicon.png