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+ repeat
37+ args {
38+ type string
39+ distinct? #true
40+ }
41+ children {
42+ node - {
43+ multiple
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 ; args ; props ; children
154+ }
155+ node default-run title= "The default binary to run by cargo run." {
156+ arg {
157+ type string
158+ }
159+ }
160+ node no-autolib title= "Disables library auto discovery."
161+ node no-autobins title= "Disables binary auto discovery."
162+ node no-autoexamples title= "Disables example auto discovery."
163+ node no-autotests title= "Disables test auto discovery."
164+ node no-autobenches title= "Disables bench auto discovery."
165+ node resolver title= "Sets the dependency resolver to use."
166+ }
167+ }
168+ }
0 commit comments