Skip to content

Commit fe0054f

Browse files
committed
Merge branch 'master' into copyright-patch
2 parents f10bdd2 + 70f2833 commit fe0054f

40 files changed

Lines changed: 2754 additions & 203 deletions

docs/GettingStarted.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ title: Getting Started
44
layout: docs
55
category: Quick Start
66
permalink: docs/getting-started.html
7+
next: navigatorios
78
---
89

910

website/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
src/react-native/docs/**
2+
core/metadata.js

website/core/Header.js

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,11 @@
44
*/
55

66
var React = require('React');
7+
var slugify = require('slugify');
78

89
var Header = React.createClass({
9-
slug: function(string) {
10-
// var accents = 'àáäâèéëêìíïîòóöôùúüûñç';
11-
var accents = '\u00e0\u00e1\u00e4\u00e2\u00e8' +
12-
'\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef' +
13-
'\u00ee\u00f2\u00f3\u00f6\u00f4\u00f9' +
14-
'\u00fa\u00fc\u00fb\u00f1\u00e7';
15-
16-
var without = 'aaaaeeeeiiiioooouuuunc';
17-
18-
return string
19-
.toString()
20-
21-
// Handle uppercase characters
22-
.toLowerCase()
23-
24-
// Handle accentuated characters
25-
.replace(
26-
new RegExp('[' + accents + ']', 'g'),
27-
function (c) { return without.charAt(accents.indexOf(c)); })
28-
29-
// Dash special characters
30-
.replace(/[^a-z0-9]/g, '-')
31-
32-
// Compress multiple dash
33-
.replace(/-+/g, '-')
34-
35-
// Trim dashes
36-
.replace(/^-|-$/g, '');
37-
},
38-
3910
render: function() {
40-
var slug = this.slug(this.props.toSlug || this.props.children);
11+
var slug = slugify(this.props.toSlug || this.props.children);
4112
var H = React.DOM['h' + this.props.level];
4213

4314
return this.transferPropsTo(

website/core/Site.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var Site = React.createClass({
5353
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
5454
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
5555
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
56-
ga('create', 'UA-387204-10', 'facebook.github.io');
56+
ga('create', 'UA-41298772-2', 'facebook.github.io');
5757
ga('send', 'pageview');
5858
5959
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)

website/core/metadata.js

Lines changed: 0 additions & 15 deletions
This file was deleted.

website/core/slugify.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* @providesModule slugify
3+
*/
4+
5+
var slugify = function(string) {
6+
// var accents = 'àáäâèéëêìíïîòóöôùúüûñç';
7+
var accents = '\u00e0\u00e1\u00e4\u00e2\u00e8' +
8+
'\u00e9\u00eb\u00ea\u00ec\u00ed\u00ef' +
9+
'\u00ee\u00f2\u00f3\u00f6\u00f4\u00f9' +
10+
'\u00fa\u00fc\u00fb\u00f1\u00e7';
11+
12+
var without = 'aaaaeeeeiiiioooouuuunc';
13+
14+
return string
15+
.toString()
16+
17+
// Handle uppercase characters
18+
.toLowerCase()
19+
20+
// Handle accentuated characters
21+
.replace(
22+
new RegExp('[' + accents + ']', 'g'),
23+
function (c) { return without.charAt(accents.indexOf(c)); })
24+
25+
// Dash special characters
26+
.replace(/[^a-z0-9]/g, '-')
27+
28+
// Compress multiple dash
29+
.replace(/-+/g, '-')
30+
31+
// Trim dashes
32+
.replace(/^-|-$/g, '');
33+
};
34+
35+
module.exports = slugify;

website/react-docgen/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
dist/

website/react-docgen/LICENSE

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
BSD License
2+
3+
For React docs generator software
4+
5+
Copyright (c) 2015, Facebook, Inc. All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice, this
11+
list of conditions and the following disclaimer.
12+
13+
* Redistributions in binary form must reproduce the above copyright notice,
14+
this list of conditions and the following disclaimer in the documentation
15+
and/or other materials provided with the distribution.
16+
17+
* Neither the name Facebook nor the names of its contributors may be used to
18+
endorse or promote products derived from this software without specific
19+
prior written permission.
20+
21+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
28+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

website/react-docgen/PATENTS

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Additional Grant of Patent Rights
2+
3+
"Software" means the React docs generator software distributed by Facebook, Inc.
4+
5+
Facebook hereby grants you a perpetual, worldwide, royalty-free, non-exclusive,
6+
irrevocable (subject to the termination provision below) license under any
7+
rights in any patent claims owned by Facebook, to make, have made, use, sell,
8+
offer to sell, import, and otherwise transfer the Software. For avoidance of
9+
doubt, no license is granted under Facebook’s rights in any patent claims that
10+
are infringed by (i) modifications to the Software made by you or a third party,
11+
or (ii) the Software in combination with any software or other technology
12+
provided by you or a third party.
13+
14+
The license granted hereunder will terminate, automatically and without notice,
15+
for anyone that makes any claim (including by filing any lawsuit, assertion or
16+
other action) alleging (a) direct, indirect, or contributory infringement or
17+
inducement to infringe any patent: (i) by Facebook or any of its subsidiaries or
18+
affiliates, whether or not such claim is related to the Software, (ii) by any
19+
party if such claim arises in whole or in part from any software, product or
20+
service of Facebook or any of its subsidiaries or affiliates, whether or not
21+
such claim is related to the Software, or (iii) by any party relating to the
22+
Software; or (b) that any right in any patent claim of Facebook is invalid or
23+
unenforceable.

website/react-docgen/README.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# react-docgen
2+
3+
`react-docgen` extracts information from React components with which
4+
you can generate documentation for those components.
5+
6+
It uses [recast][] to parse the provided files into an AST, looks for React
7+
component definitions, and inspects the `propTypes` and `getDefaultProps`
8+
declarations. The output is a JSON blob with the extracted information.
9+
10+
Note that component definitions must follow certain guidelines in order to be
11+
analyzable by this tool. We will work towards less strict guidelines, but there
12+
is a limit to what is statically analyzable.
13+
14+
## Install
15+
16+
Install the module directly from npm:
17+
18+
```
19+
npm install -g react-docgen
20+
```
21+
22+
## CLI
23+
24+
Installing the module adds a `react-docgen` executable which allows you do convert
25+
a single file, multiple files or an input stream. We are trying to make the
26+
executable as versatile as possible so that it can be integrated into many
27+
workflows.
28+
29+
```
30+
Usage: react-docgen [path]... [options]
31+
32+
path A component file or directory. If no path is provided it reads from stdin.
33+
34+
Options:
35+
-o FILE, --out FILE store extracted information in FILE
36+
--pretty pretty print JSON
37+
-x, --extension File extensions to consider. Repeat to define multiple extensions. Default: [js,jsx]
38+
-i, --ignore Folders to ignore. Default: [node_modules,__tests__]
39+
40+
Extract meta information from React components.
41+
If a directory is passed, it is recursively traversed.
42+
```
43+
44+
## API
45+
46+
The tool can also be used programmatically to extract component information:
47+
48+
```js
49+
var reactDocs = require('react-docgen');
50+
var componentInfo reactDocs.parseSource(src);
51+
```
52+
53+
## Guidelines
54+
55+
- Modules have to export a single component, and only that component is
56+
analyzed.
57+
- `propTypes` must be an object literal or resolve to an object literal in the
58+
same file.
59+
- The `return` statement in `getDefaultProps` must consist of an object literal.
60+
61+
## Example
62+
63+
For the following component
64+
65+
```js
66+
var React = require('react');
67+
68+
/**
69+
* General component description.
70+
*/
71+
var Component = React.createClass({
72+
propTypes: {
73+
/**
74+
* Description of prop "foo".
75+
*/
76+
foo: React.PropTypes.number,
77+
/**
78+
* Description of prop "bar" (a custom validation function).
79+
*/
80+
bar: function(props, propName, componentName) {
81+
// ...
82+
},
83+
baz: React.PropTypes.oneOfType([
84+
React.PropTypes.number,
85+
React.PropTypes.string
86+
]),
87+
},
88+
89+
getDefaultProps: function() {
90+
return {
91+
foo: 42,
92+
bar: 21
93+
};
94+
},
95+
96+
render: function() {
97+
// ...
98+
}
99+
});
100+
101+
module.exports = Component;
102+
```
103+
104+
we are getting this output:
105+
106+
```
107+
{
108+
"props": {
109+
"foo": {
110+
"type": {
111+
"name": "number"
112+
},
113+
"required": false,
114+
"description": "Description of prop \"foo\".",
115+
"defaultValue": {
116+
"value": "42",
117+
"computed": false
118+
}
119+
},
120+
"bar": {
121+
"type": {
122+
"name": "custom"
123+
},
124+
"required": false,
125+
"description": "Description of prop \"bar\" (a custom validation function).",
126+
"defaultValue": {
127+
"value": "21",
128+
"computed": false
129+
}
130+
},
131+
"baz": {
132+
"type": {
133+
"name": "union",
134+
"value": [
135+
{
136+
"name": "number"
137+
},
138+
{
139+
"name": "string"
140+
}
141+
]
142+
},
143+
"required": false,
144+
"description": ""
145+
}
146+
},
147+
"description": "General component description."
148+
}
149+
```
150+
151+
## Result data structure
152+
153+
The structure of the JSON blob / JavaScript object is as follows:
154+
155+
```
156+
{
157+
"description": string
158+
"props": {
159+
"<propName>": {
160+
"type": {
161+
"name": "<typeName>",
162+
["value": <typeValue>]
163+
["raw": string]
164+
},
165+
"required": boolean,
166+
"description": string,
167+
["defaultValue": {
168+
"value": number | string,
169+
"computed": boolean
170+
}]
171+
},
172+
...
173+
},
174+
["composes": <componentNames>]
175+
}
176+
```
177+
178+
[recast]: https://github.com/benjamn/recast

0 commit comments

Comments
 (0)