Skip to content

Commit a7da8fc

Browse files
authored
docs and readme (#15)
1 parent d17f63f commit a7da8fc

21 files changed

+957
-152
lines changed

.prettierrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"tabWidth": 2,
3+
"useTabs": false
4+
}

README.md

+28-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# `codemirror-json-schema`
2-
3-
Builds on `@codemirror/lang-json`'s and `codemirror-json5`'s grammars with JSONSchema support!
1+
Codemirror extensions that add on `@codemirror/lang-json`'s and `codemirror-json5`'s grammars to add JSONSchema support!
42

53
![screenshot of the examples with json4 and json5 support enabled](./dev/public/example.png)
64

@@ -10,15 +8,14 @@ It's at a very early stage, but usable.
108

119
### json4
1210

13-
- [x] `lint`s: validates json against schema
14-
- [x] `hint`s: provides code completion (no complex types yet)
15-
- [x] `info`s: provides hover tooltip
11+
- `lint`s: validates json against schema
12+
- `hint`s: provides code completion (no complex types yet)
13+
- `info`s: provides hover tooltip
1614

1715
### json5
1816

19-
- [x] `lint`s: validates json against schema
20-
- [x] `info`s: provides hover tooltip
21-
- [ ] `hint`s: provides code completion
17+
-`lint`s: validates json against schema
18+
-`info`s: provides hover tooltip
2219

2320
## Usage
2421

@@ -34,8 +31,17 @@ npm install --save @codemirror/lang-json codemirror-json-schema
3431
import { json } from "@codemirror/lang-json";
3532
import { jsonSchemaLinting, jsonSchemaHover } from "codemirror-json-schema";
3633

34+
const schema = {
35+
type: "object",
36+
properties: {
37+
example: {
38+
type: "boolean",
39+
},
40+
},
41+
};
42+
3743
const state = EditorState.create({
38-
doc: jsonText,
44+
doc: `{ "example": true }`,
3945
extensions: [
4046
json(),
4147
linter(jsonParseLinter()),
@@ -61,10 +67,18 @@ import {
6167
jsonSchemaHover,
6268
} from "codemirror-json-schema/json5";
6369

70+
const schema = {
71+
type: "object",
72+
properties: {
73+
example: {
74+
type: "boolean",
75+
},
76+
},
77+
};
78+
6479
const json5State = EditorState.create({
65-
doc: json5Text,
80+
doc: `{ example: true }`,
6681
extensions: [
67-
...commonExtensions,
6882
json5(),
6983
linter(json5ParseLinter()),
7084
linter(json5SchemaLinter(schema)),
@@ -73,11 +87,11 @@ const json5State = EditorState.create({
7387
});
7488
```
7589

76-
You can start with the [deployed example](https://github.com/acao/cm6-json-schema/blob/main/dev/index.ts) to learn advanced usage.
90+
You can start with the [deployed example](https://github.com/acao/cm6-json-schema/blob/main/dev/index.ts) to see a more comprehensive setup.
7791

7892
Many more docs to come, including API docs!
7993

80-
## Current constraints:
94+
## Current Constraints:
8195

8296
- only linting & hover is available for `oneOf`, `anyOf`, `allOf` and other [schema combination methods](https://json-schema.org/understanding-json-schema/reference/combining.html)
8397
- it only works with one json schema instance at a time, and doesn't yet fetch remote schemas. schema service coming soon!

dev/sample-text.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const jsonText = `{
66
"email": "email",
77
"url": "h"
88
}],
9-
"type":
9+
"type": ""
1010
}`;
1111
export const json5Text = `{
1212
"name": "lexunicon",

docs/.nojekyll

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
TypeDoc added this file to prevent GitHub Pages from using Jekyll. You can turn off this behavior by setting the `githubPages` option to false.

docs/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
codemirror-json-schema
2+
3+
# codemirror-json-schema
4+
5+
## Table of contents
6+
7+
### Modules
8+
9+
- [index](modules/index.md)
10+
- [json5](modules/json5.md)

0 commit comments

Comments
 (0)