[Docs] Better README for react-tools
Cheng Lou committed
Jul 11, 2014 at 15:09 UTC
b38518ff4d34b991c0db6def41f746dd10228897
1 file changed
+36
-5
npm-react-tools/README.md
+36
-5
@@ -1,6 +1,6 @@
1
# react-tools
2
3
-This package compliments the usage of React. It ships with tools that are often used in conjunction.
3
+This package compliments the usage of [React](http://facebook.github.io/react/). It ships with tools that are often used in conjunction.
4
5
## JSX
6
@@ -10,14 +10,45 @@ This package installs a `jsx` executable that can be used to transform JSX into
10
11
### Command Line
12
13
-```sh
14
-jsx input > output
15
-```
13
+ Usage: jsx [options] <source directory> <output directory> [<module ID> [<module ID> ...]]
14
+
15
+ Options:
16
+
17
+ -h, --help output usage information
18
+ -V, --version output the version number
19
+ -c, --config [file] JSON configuration file (no file or - means STDIN)
20
+ -w, --watch Continually rebuild
21
+ -x, --extension <js | coffee | ...> File extension to assume when resolving module identifiers
22
+ --relativize Rewrite all module identifiers to be relative
23
+ --follow-requires Scan modules for required dependencies
24
+ --cache-dir <directory> Alternate directory to use for disk cache
25
+ --no-cache-dir Disable the disk cache
26
+ --source-charset <utf8 | win1252 | ...> Charset of source (default: utf8)
27
+ --output-charset <utf8 | win1252 | ...> Charset of output (default: utf8)
28
+ --harmony Turns on JS transformations such as ES6 Classes etc.
29
+
30
+## API
31
+
32
+### `transform(inputString, options)`
33
17
-### API
34
+option | values | default
35
+-------|--------|---------
36
+`sourceMap` | `true`: append inline source map at the end of the transformed source | `false`
37
+`harmony` | `true`: enable ES6 features | `false`
38
+`filename` | the output filename for the source map | `"source.js"`
39
40
```js
41
var reactTools = require('react-tools');
42
43
reactTools.transform(string, options);
44
```
45
+
46
+### `transformWithDetails(inputString, options)`
47
+
48
+Just like `transform`, but outputs an object:
49
+```js
50
+{
51
+ code: outputString,
52
+ sourceMap: theSourceMap // Only if the `sourceMap` option is `true`.
53
+}
54
+```