Skip to content

Commit acb1ba3

Browse files
authored
Merge pull request #10 from open-rpc/fix/write-readme-on-usage
fix: write readme on how to use
2 parents 70dc90c + 5565477 commit acb1ba3

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# docs-react
2+
OpenRPC documentation as a react component
3+
4+
#### What is this?
5+
This is a react component that will render documentation for a given OpenRPC document.
6+
7+
**Screenshot**:
8+
9+
![image](https://user-images.githubusercontent.com/364566/54795109-1b1f5b80-4c08-11e9-9ba9-cc2f2d96c692.png)
10+
11+
12+
#### How do I use this?
13+
14+
##### Installation:
15+
```
16+
npm install --save @open-rpc/docs-react
17+
```
18+
##### Usage:
19+
```
20+
import Documentation from "@open-rpc/docs-react";
21+
```
22+
and then use it somewhere:
23+
24+
```
25+
<Documentation schema={schema} />
26+
```
27+
28+
##### Example in a new project:
29+
30+
###### create a new typescript project with `create-react-app`
31+
32+
```
33+
npx create-react-app <appname> --typescript
34+
```
35+
36+
```
37+
cd <appname>
38+
npm install .
39+
npm install @open-rpc/docs-react @open-rpc/meta-schema --save
40+
```
41+
42+
###### index.ts
43+
```
44+
import React from 'react';
45+
import ReactDOM from 'react-dom';
46+
import Documentation from "@open-rpc/docs-react";
47+
import { types } from '@open-rpc/meta-schema';
48+
49+
const schema: types.OpenRPC = {
50+
openrpc: "1.0.0-rc1",
51+
info: {
52+
"version": "0.0.0-development",
53+
"title": "My New API"
54+
},
55+
methods: []
56+
};
57+
58+
ReactDOM.render(<Documentation schema={schema} />, document.getElementById("root"));
59+
60+
```
61+
62+
###### screenshot
63+
![image](https://user-images.githubusercontent.com/364566/54797953-920e2180-4c13-11e9-9ff8-723a836d0e2c.png)

0 commit comments

Comments
 (0)