浏览代码

Add React Native documentation

Thibaut 10 年之前
父节点
当前提交
eabcb6179a

二进制
assets/images/icons.png


二进制
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",
     "2015-08-03",
     "Added an icon in the sidebar to constrain the width of the UI (visible when applicable)."
     "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',
     'MIT',
     'https://raw.githubusercontent.com/kriskowal/q/v1/LICENSE'
     'https://raw.githubusercontent.com/kriskowal/q/v1/LICENSE'
   ], [
   ], [
-    'React',
+    'React, React Native',
     '2013-2015 Facebook Inc.',
     '2013-2015 Facebook Inc.',
     'CC BY',
     'CC BY',
     'https://raw.githubusercontent.com/facebook/react/master/LICENSE-docs'
     'https://raw.githubusercontent.com/facebook/react/master/LICENSE-docs'

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

@@ -4,7 +4,7 @@
   width: 1rem;
   width: 1rem;
   height: 1rem;
   height: 1rem;
   background-image: image-url('icons.png');
   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) {
 @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
@@ -111,3 +111,4 @@
 %icon-contract              { background-position: -7rem -8rem; }
 %icon-contract              { background-position: -7rem -8rem; }
 %icon-expand-white          { background-position: -8rem -8rem; }
 %icon-expand-white          { background-position: -8rem -8rem; }
 %icon-contract-white        { background-position: -9rem -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 {
 ._react {
   > h2 { @extend %block-heading; }
   > h2 { @extend %block-heading; }
   > h3 { @extend %block-label, %label-blue; }
   > h3 { @extend %block-label, %label-blue; }
-  > h4 { font-size: 1em; }
+  > h4 { @extend %block-label; }
 
 
   code { @extend %label; }
   code { @extend %label; }
   blockquote { @extend %note; }
   blockquote { @extend %note; }

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

@@ -5,10 +5,10 @@ module Docs
         @doc = at_css('.inner-content')
         @doc = at_css('.inner-content')
 
 
         if root_page?
         if root_page?
-          at_css('h1').content = 'React Documentation'
+          at_css('h1').content = context[:root_title]
         end
         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|
         css('a.anchor').each do |node|
           node.parent['id'] = node['name']
           node.parent['id'] = node['name']
@@ -20,10 +20,23 @@ module Docs
           node.content = node.content
           node.content = node.content
         end
         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|
         css('blockquote > p:first-child').each do |node|
           node.remove if node.content.strip == 'Note:'
           node.remove if node.content.strip == 'Note:'
         end
         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
         doc
       end
       end
     end
     end

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

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

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

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

二进制
public/icons/docs/react_native/16.png


二进制
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