Skip to content

Commit b6c96a0

Browse files
committed
new schema format/spec
1 parent 2315969 commit b6c96a0

File tree

3 files changed

+658
-1
lines changed

3 files changed

+658
-1
lines changed

SCHEMA-SPEC.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ constrain the allowed semantics of a KDL document. This can be used for many
66
purposes: documentation for users, automated verification, or even automated
77
generation of bindings!
88

9-
This document describes KDL Schema version `1.0.0`. It was released on September 11, 2021.
9+
This document describes KDL Schema version `2.0.0`. It is unreleased.
1010

1111
## The Formal Schema
1212

@@ -39,6 +39,14 @@ None.
3939
* `tag-names` (optional): [Validations](#validation-nodes) to apply to the _names_ of tags of child nodes.
4040
* `other-tags-allowed` (optional): Whether to allow node tags other than the ones explicitly listed here. Defaults to `#false`.
4141

42+
#### Example
43+
44+
```kdl
45+
document {
46+
47+
}
48+
```
49+
4250
### `info` node
4351

4452
The `info` node describes the schema itself.

schema/cargo.kdl

+172
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
@kdl:schema "https://github.com/kdl-org/kdl/blob/main/schema/kdl-schema.kdl"
2+
3+
metadata {
4+
// TODO: update this link when we're ready to release something.
5+
link "https://github.com/kdl-org/kdl/blob/main/schema/cargo.kdl" rel=self
6+
title "Cargo Schema" lang=en
7+
description "KDL-based translation of the Cargo.toml schema." lang=en
8+
author "Kat Marchán" {
9+
link "https://github.com/zkat" rel=self
10+
}
11+
link "https://github.com/kdl-org/kdl" rel=documentation
12+
link "https://doc.rust-lang.org/cargo/reference/manifest.html" rel=documentation
13+
license "Creative Commons Attribution-ShareAlike 4.0 International License" spdx=CC-BY-SA-4.0 {
14+
link "https://creativecommons.org/licenses/by-sa/4.0/" lang=en
15+
}
16+
}
17+
18+
children {
19+
node package title="Describes a package" {
20+
children {
21+
node name title="The name of the package" {
22+
required
23+
arg {
24+
type string
25+
pattern #"^[a-zA-Z0-0\-_]+$"#
26+
}
27+
}
28+
node version title="The version of the package." {
29+
arg {
30+
type string
31+
// From https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string
32+
pattern #"^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$"#
33+
}
34+
}
35+
node authors title="The authors of the package." {
36+
repeatable
37+
args {
38+
distinct
39+
type string
40+
}
41+
children {
42+
node - {
43+
repeatable
44+
arg title="Name" {
45+
type string
46+
}
47+
prop email title="Email address" {
48+
type string
49+
format email
50+
}
51+
prop about title="Brief note about author (role, etc)" {
52+
type string
53+
}
54+
}
55+
}
56+
}
57+
node edition title="The Rust edition." {
58+
arg {
59+
type string
60+
enum "2015" "2018" "2021" "2024"
61+
}
62+
}
63+
node rust-version title="The minimal supported Rust version." {
64+
arg {
65+
type string
66+
}
67+
}
68+
node description title="A description of the package." {
69+
arg {
70+
type string
71+
}
72+
}
73+
node documentation title="URL of the package documentation." {
74+
arg {
75+
type string
76+
format url
77+
}
78+
}
79+
node readme title="Path to the package’s README file." {
80+
arg {
81+
type string #boolean
82+
}
83+
}
84+
node homepage title="URL of the package homepage." {
85+
arg {
86+
type string
87+
format url
88+
}
89+
}
90+
node repository title="URL of the package source repository." {
91+
arg {
92+
type string
93+
format url
94+
}
95+
}
96+
node license title="The package license." {
97+
arg {
98+
type string
99+
}
100+
}
101+
node license-file title="Path to the text of the license." {
102+
arg {
103+
type string
104+
}
105+
}
106+
node keywords title="Keywords for the package." {
107+
args {
108+
type string
109+
// No pattern because keyword restrictions are only on
110+
// crates.io
111+
}
112+
}
113+
node categories title="Categories of the package." {
114+
args {
115+
type string
116+
// No pattern because category restrictions are only on
117+
// crates.io
118+
}
119+
}
120+
node workspace title="Path to the workspace for the package." {
121+
arg {
122+
type string
123+
}
124+
}
125+
node build title="Path to the package build script." {
126+
arg {
127+
type string boolean
128+
}
129+
}
130+
node links title="Name of the native library the package links with." {
131+
arg {
132+
type string
133+
}
134+
}
135+
node exclude title="Files to exclude when publishing." {
136+
args {
137+
type string
138+
}
139+
}
140+
node include title="Files to include when publishing." {
141+
args {
142+
type string
143+
}
144+
}
145+
node publish title="Can be used to prevent publishing the package." {
146+
// TODO: This is a good example of where we might need smarter
147+
// comstraints ("either a single boolean, or 1+ strings")
148+
args {
149+
type string boolean
150+
}
151+
]
152+
node metadata title="Extra settings for external tools." {
153+
repeat
154+
args
155+
props {
156+
allow-others
157+
}
158+
}
159+
node default-run title="The default binary to run by cargo run." {
160+
arg {
161+
type string
162+
}
163+
}
164+
node no-autolib title="Disables library auto discovery."
165+
node no-autobins title="Disables binary auto discovery."
166+
node no-autoexamples title="Disables example auto discovery."
167+
node no-autotests title="Disables test auto discovery."
168+
node no-autobenches title="Disables bench auto discovery."
169+
node resolver title="Sets the dependency resolver to use."
170+
}
171+
}
172+
}

0 commit comments

Comments
 (0)