Skip to content

Commit 333e52a

Browse files
authored
Merge branch 'develop' into deps/dev
2 parents c6d622a + 0fcf8b7 commit 333e52a

File tree

4 files changed

+155
-2
lines changed

4 files changed

+155
-2
lines changed

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,31 @@ Explore the demo to see how KoalaKeys works and to get ideas for creating custom
9595
9696
4. Open `index.html` to view the cheat sheet collection.
9797
98+
## Schema
99+
100+
Validate your YAML with the published JSON Schema:
101+
102+
- Public URL: https://rtuszik.github.io/KoalaKeys/schema/cheatsheet.schema.json
103+
- Per-file modeline (first line in each YAML):
104+
105+
```
106+
# yaml-language-server: $schema=https://rtuszik.github.io/KoalaKeys/schema/cheatsheet.schema.json
107+
```
108+
109+
- Neovim yamlls mapping (optional):
110+
111+
```lua
112+
require('lspconfig').yamlls.setup({
113+
settings = {
114+
yaml = {
115+
schemas = {
116+
["https://rtuszik.github.io/KoalaKeys/schema/cheatsheet.schema.json"] = "cheatsheets/*.yaml",
117+
},
118+
},
119+
},
120+
})
121+
```
122+
98123
## Contributing
99124
100125
Contributions are welcome! Feel free to submit issues, feature requests, or pull requests.

docs/schema/cheatsheet.schema.json

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
"$id": "https://rtuszik.github.io/KoalaKeys/schema/cheatsheet.schema.json",
4+
"title": "KoalaKeys Cheatsheet",
5+
"description": "Schema for KoalaKeys YAML cheatsheets.",
6+
"type": "object",
7+
"additionalProperties": false,
8+
"required": ["title", "layout", "shortcuts"],
9+
"properties": {
10+
"title": {
11+
"type": "string",
12+
"minLength": 1,
13+
"description": "Title of the cheatsheet."
14+
},
15+
"RenderKeys": {
16+
"type": "boolean",
17+
"default": true,
18+
"description": "When true (default), render keyboard layout with highlighted keys."
19+
},
20+
"AllowText": {
21+
"type": "boolean",
22+
"default": false,
23+
"description": "When true, free-form shortcut text is allowed; requires RenderKeys=false."
24+
},
25+
"layout": {
26+
"type": "object",
27+
"additionalProperties": false,
28+
"required": ["keyboard", "system"],
29+
"properties": {
30+
"keyboard": {
31+
"type": "string",
32+
"enum": ["US", "UK", "DE", "FR", "ES", "DVORAK"],
33+
"description": "Keyboard layout."
34+
},
35+
"system": {
36+
"type": "string",
37+
"enum": ["Darwin", "Windows", "Linux"],
38+
"description": "Operating system."
39+
}
40+
}
41+
},
42+
"shortcuts": {
43+
"type": "object",
44+
"minProperties": 1,
45+
"description": "Categories mapped to shortcut definitions.",
46+
"additionalProperties": {
47+
"type": "object",
48+
"minProperties": 1
49+
}
50+
}
51+
},
52+
"allOf": [
53+
{
54+
"description": "AllowText=true requires RenderKeys=false.",
55+
"if": {
56+
"properties": { "AllowText": { "const": true } },
57+
"required": ["AllowText"]
58+
},
59+
"then": {
60+
"properties": {
61+
"RenderKeys": { "const": false },
62+
"shortcuts": {
63+
"additionalProperties": {
64+
"additionalProperties": { "$ref": "#/$defs/shortcutEntry" }
65+
}
66+
}
67+
}
68+
}
69+
},
70+
{
71+
"description": "When AllowText is not true, restrict shortcut key syntax.",
72+
"if": {
73+
"not": {
74+
"properties": { "AllowText": { "const": true } },
75+
"required": ["AllowText"]
76+
}
77+
},
78+
"then": {
79+
"properties": {
80+
"shortcuts": {
81+
"additionalProperties": {
82+
"type": "object",
83+
"minProperties": 1,
84+
"patternProperties": {
85+
"^[A-Za-z0-9+⌘⌥⌃⇧←→↑↓\\s\\-\\|\\[\\],.:/`\"?<>=\\\\⌃]+$": {
86+
"$ref": "#/$defs/shortcutEntry"
87+
}
88+
},
89+
"additionalProperties": false
90+
}
91+
}
92+
}
93+
}
94+
}
95+
],
96+
"$defs": {
97+
"shortcutEntry": {
98+
"type": "object",
99+
"additionalProperties": false,
100+
"required": ["description"],
101+
"properties": {
102+
"description": {
103+
"type": "string",
104+
"minLength": 1,
105+
"description": "Human-readable description of the shortcut."
106+
}
107+
},
108+
"examples": [
109+
{ "description": "Copy selected item" }
110+
]
111+
}
112+
},
113+
"examples": [
114+
{
115+
"title": "KoalaKeys",
116+
"RenderKeys": true,
117+
"AllowText": false,
118+
"layout": { "keyboard": "US", "system": "Darwin" },
119+
"shortcuts": {
120+
"General": {
121+
"CMD+C": { "description": "Copy selected item" },
122+
"CMD+Right": { "description": "Move cursor to end of line" }
123+
}
124+
}
125+
}
126+
]
127+
}

src/validate_yaml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ def validate_layout(data):
5656
logger.error("Layout must be a dictionary")
5757
return False
5858

59-
valid_keyboards = ["US", "UK", "DE", "FR", "ES"]
60-
valid_systems = ["Darwin", "Linux", "Windows"]
59+
valid_keyboards = ['US', 'UK', 'DE', 'FR', 'ES', 'DVORAK']
60+
valid_systems = ['Darwin', 'Linux', 'Windows']
6161
is_valid = True
6262

6363
if "keyboard" in data["layout"] and data["layout"]["keyboard"] not in valid_keyboards:

yaml_cheatsheet_spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ Valid values for `keyboard` are:
6161
- `DE` (German)
6262
- `FR` (French)
6363
- `ES` (Spanish)
64+
- `DVORAK`
6465

6566
### System Types
6667

0 commit comments

Comments
 (0)