|
1 |
| -[](https://npmjs.com/package/unist-builder) |
| 1 | +# unist-builder [![Build Status][travis-badge]][travis] [![Coverage Status][codecov-badge]][codecov] |
2 | 2 |
|
3 |
| -# unist-builder |
| 3 | +Helper for creating [**unist**][unist] trees with [hyperscript][]-like syntax. |
4 | 4 |
|
5 |
| -[![Build Status][travis-badge]][travis] [![Dependency Status][david-badge]][david] |
| 5 | +## Installation |
6 | 6 |
|
7 |
| -Helper for creating [unist][] trees with [hyperscript][]-like syntax. |
| 7 | +[npm][]: |
8 | 8 |
|
9 |
| -[unist]: https://github.com/wooorm/unist |
10 |
| -[hyperscript]: https://github.com/dominictarr/hyperscript |
11 |
| - |
12 |
| -[travis]: https://travis-ci.org/eush77/unist-builder |
13 |
| -[travis-badge]: https://travis-ci.org/eush77/unist-builder.svg?branch=master |
14 |
| -[david]: https://david-dm.org/eush77/unist-builder |
15 |
| -[david-badge]: https://david-dm.org/eush77/unist-builder.png |
| 9 | +```bash |
| 10 | +npm install unist-builder |
| 11 | +``` |
16 | 12 |
|
17 |
| -## Example |
| 13 | +## Usage |
18 | 14 |
|
19 | 15 | ```js
|
20 | 16 | var u = require('unist-builder')
|
@@ -57,28 +53,74 @@ results in the following tree:
|
57 | 53 |
|
58 | 54 | ## API
|
59 | 55 |
|
60 |
| -#### `u(type, [props], [value])` |
| 56 | +### `u(type[, props][, children|value])` |
61 | 57 |
|
62 |
| -`type`: `String`<br> |
63 |
| -`props`: `Object`<br> |
64 |
| -`value`: `String`<br> |
| 58 | +Creates a node from `props`, `children`, and optionally `value`. |
65 | 59 |
|
66 |
| -Creates a node from `props` and optional `value`. |
| 60 | +###### Signatures |
67 | 61 |
|
68 |
| -#### `u(type, [props], children)` |
| 62 | +* `u(type[, props], children)` — create a [parent][] |
| 63 | +* `u(type[, props], value)` — create a [text][] |
| 64 | +* `u(type[, props])` — create a void node |
69 | 65 |
|
70 |
| -`type`: `String`<br> |
71 |
| -`props`: `Object`<br> |
72 |
| -`children`: `Array`<br> |
| 66 | +###### Parameters |
73 | 67 |
|
74 |
| -Creates a node from `props` and given child nodes. |
| 68 | +* `type` (`string`) — node [type][] |
| 69 | +* `props` (`Object`) — other values assigned to `node` |
| 70 | +* `children` ([`Array.<Node>`][node]) — children of `node` |
| 71 | +* `value` (`*`) — value of `node` (cast to string) |
75 | 72 |
|
76 |
| -## Install |
| 73 | +###### Returns |
77 | 74 |
|
78 |
| -``` |
79 |
| -npm install unist-builder |
80 |
| -``` |
| 75 | +[`Node`][node]. |
| 76 | + |
| 77 | +## Related |
| 78 | + |
| 79 | +* [`unist-builder-blueprint`](https://github.com/syntax-tree/unist-builder-blueprint) |
| 80 | + — Convert unist trees to `unist-builder` notation |
| 81 | +* [`hastscript`](https://github.com/syntax-tree/hastscript) |
| 82 | + — Create [hast][] elements |
| 83 | + |
| 84 | +## Contribute |
| 85 | + |
| 86 | +See [`contributing.md` in `syntax-tree/unist`][contributing] for ways to get |
| 87 | +started. |
| 88 | + |
| 89 | +This organisation has a [Code of Conduct][coc]. By interacting with this |
| 90 | +repository, organisation, or community you agree to abide by its terms. |
81 | 91 |
|
82 | 92 | ## License
|
83 | 93 |
|
84 |
| -MIT |
| 94 | +[MIT][license] © Eugene Sharygin |
| 95 | + |
| 96 | +<!-- Definitions --> |
| 97 | + |
| 98 | +[travis-badge]: https://img.shields.io/travis/syntax-tree/unist-builder.svg |
| 99 | + |
| 100 | +[travis]: https://travis-ci.org/syntax-tree/unist-builder |
| 101 | + |
| 102 | +[codecov-badge]: https://img.shields.io/codecov/c/github/syntax-tree/unist-builder.svg |
| 103 | + |
| 104 | +[codecov]: https://codecov.io/github/syntax-tree/unist-builder |
| 105 | + |
| 106 | +[npm]: https://docs.npmjs.com/cli/install |
| 107 | + |
| 108 | +[license]: license |
| 109 | + |
| 110 | +[contributing]: https://github.com/syntax-tree/unist/blob/master/contributing.md |
| 111 | + |
| 112 | +[coc]: https://github.com/syntax-tree/unist/blob/master/code-of-conduct.md |
| 113 | + |
| 114 | +[unist]: https://github.com/syntax-tree/unist |
| 115 | + |
| 116 | +[hast]: https://github.com/syntax-tree/hast |
| 117 | + |
| 118 | +[hyperscript]: https://github.com/dominictarr/hyperscript |
| 119 | + |
| 120 | +[node]: https://github.com/syntax-tree/unist#node |
| 121 | + |
| 122 | +[parent]: https://github.com/syntax-tree/unist#parent |
| 123 | + |
| 124 | +[text]: https://github.com/syntax-tree/unist#text |
| 125 | + |
| 126 | +[type]: https://github.com/syntax-tree/unist#type |
0 commit comments