Skip to content

Commit 12166a4

Browse files
committed
feat: add keyword
1 parent 51b4856 commit 12166a4

File tree

8 files changed

+40
-6
lines changed

8 files changed

+40
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ From the repo:
2121

2222
## Supported JSON Schema keywords
2323

24-
- [ ] [\$comment](https://yanick.github.io/jsonschematic/#$comment)
24+
- [x] [\$comment](https://yanick.github.io/jsonschematic/#$comment)
2525
- [x] [\$id](https://yanick.github.io/jsonschematic/#$id)
2626
- [x] [\$ref](https://yanick.github.io/jsonschematic/#$ref)
2727
- [x] [\$schema](https://yanick.github.io/jsonschematic/#$schema)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@
123123
"build:docs": "webpack --config ./webpack.docs.config.js",
124124
"build:watch": "webpack --watch",
125125
"dev": "NODE_ENV=development webpack-dev-server",
126+
"dev:docs": "NODE_ENV=development webpack-dev-server --config webpack.docs.config.js",
126127
"lint": "npm-run-all --parallel \"lint:prettier -- {@}\" \"lint:eslint -- {@}\" --",
127128
"lint:eslint": "./scripts/eslint",
128129
"lint:eslint:fix": "npm run lint:eslint -- --fix",

package.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ eslintConfig:
4545
modules: true
4646
plugins:
4747
- svelte3
48-
rules:
48+
rules:
4949
"lodash/prefer-lodash-method": off
5050
overrides:
5151
- files: ["*.svelte"]
@@ -61,6 +61,7 @@ scripts:
6161
'build:watch': webpack --watch
6262
"build:docs": webpack --config ./webpack.docs.config.js
6363
dev: NODE_ENV=development webpack-dev-server
64+
"dev:docs": NODE_ENV=development webpack-dev-server --config webpack.docs.config.js
6465
start: node ./bin/jsonschematic.js --local --schema_dir examples
6566
release: standard-version
6667
storybook: start-storybook
@@ -77,13 +78,13 @@ scripts:
7778
"lint:eslint:fix": npm run lint:eslint -- --fix
7879
"lint:fix": npm-run-all "lint:eslint:fix -- {@}" "lint:prettier:fix -- {@}" --
7980

80-
publishConfig: { "registry": "https://npm.pkg.github.com/" }
81+
publishConfig: { "registry": "https://npm.pkg.github.com/" }
8182

8283
standard-version:
8384
skip:
84-
tag: true
85+
tag: true
8586
types:
86-
- type: bug
87+
- type: bug
8788
section: Bug Fixes
8889
- {"type": "feat", "section": "Features"}
8990
- {"type": "fix", "section": "Bug Fixes"}

src/components/Examples/Example.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,12 @@
6565
.example > * {
6666
flex: 1;
6767
height: min-content;
68+
min-width: 50%;
6869
}
6970
7071
pre {
7172
background-color: #f0f0f0;
73+
overflow: scroll;
7274
}
7375
7476
.edit_me {

src/components/Examples/examples.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
export default [
2+
{
3+
title: "with a $comment",
4+
description: "this is the description",
5+
$comment: "and this is the comment",
6+
},
27
{ title: "'true' as the schema", type: "array", items: true },
38
{ title: "'false' as the schema", type: "array", items: false },
49
{

src/components/Instance/index.svelte

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@
2727
<div class="description">{description}</div>
2828
{/if}
2929

30+
{#if comment}
31+
<blockquote class="comment">{comment}</blockquote>
32+
{/if}
33+
3034
{#if expanded_def.writeOnly}
3135
<div class="writeOnly">write-only</div>
3236
{/if}
@@ -117,6 +121,7 @@
117121
import Not from "./Not.svelte";
118122
119123
let schema,
124+
comment,
120125
types,
121126
items,
122127
ref,
@@ -150,6 +155,7 @@
150155
enum: enumeration,
151156
const: constant,
152157
properties,
158+
$comment: comment,
153159
} = expanded_def);
154160
155161
// always pass an array, to make it easier
@@ -228,10 +234,15 @@
228234
grid-column: span 2;
229235
}
230236
231-
.description {
237+
.description,
238+
.comment {
232239
grid-column: span 2;
233240
}
234241
242+
.comment {
243+
font-style: italic;
244+
}
245+
235246
.title {
236247
grid-column: span 2;
237248
color: var(--color-blue);

src/components/Instance/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,11 @@ tap.test("default", async (t) => {
1919

2020
t.ok(getByText('"potato"'));
2121
});
22+
23+
tap.test("$comment", async (t) => {
24+
const { getByText } = render(Instance, {
25+
definition: { $comment: "we have comments" },
26+
});
27+
28+
t.ok(getByText("we have comments"));
29+
});

webpack.docs.config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,10 @@ module.exports = {
5252
}),
5353
],
5454
devtool: prod ? false : "source-map",
55+
devServer: {
56+
contentBase: "./docs",
57+
publicPath: "/build",
58+
hot: false,
59+
liveReload: true,
60+
},
5561
};

0 commit comments

Comments
 (0)