Skip to content

Commit 8542c37

Browse files
author
WebFreak001
committed
Added auto completion to dub.json
1 parent d5eb32b commit 8542c37

File tree

2 files changed

+334
-0
lines changed

2 files changed

+334
-0
lines changed

json-validation/dub.schema.json

Lines changed: 328 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,328 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"title": "dub Package Schema",
4+
"type": "object",
5+
"definitions": {
6+
"packageName": {
7+
"type": "string",
8+
"pattern": "^[-a-z0-9_]+$"
9+
},
10+
"stringArray": {
11+
"type": "array",
12+
"items": {
13+
"type": "string"
14+
},
15+
"minItems": 1,
16+
"uniqueItems": true
17+
},
18+
"buildOptions": {
19+
"type": "array",
20+
"items": {
21+
"type": "string",
22+
"enum": [
23+
"debugMode",
24+
"releaseMode",
25+
"coverage",
26+
"debugInfo",
27+
"debugInfoC",
28+
"alwaysStackFrame",
29+
"stackStomping",
30+
"inline",
31+
"noBoundsCheck",
32+
"optimize",
33+
"profile",
34+
"unittests",
35+
"verbose",
36+
"ignoreUnknownPragmas",
37+
"syntaxOnly",
38+
"warnings",
39+
"warningsAsErrors",
40+
"ignoreDeprecations",
41+
"deprecationWarnings",
42+
"deprecationErrors",
43+
"property"
44+
]
45+
},
46+
"minItems": 1,
47+
"uniqueItems": true,
48+
"description": "List of build option identifiers (corresponding to compiler flags)"
49+
},
50+
"lowBuildSettings": {
51+
"properties": {
52+
"systemDependencies": {
53+
"type": "string",
54+
"description": "A textual description of the required system dependencies (external C libraries) required by the package. This will be visible on the registry and will be displayed in case of linker errors"
55+
},
56+
"buildRequirements": {
57+
"type": "array",
58+
"items": {
59+
"type": "string",
60+
"enum": [
61+
"allowWarnings",
62+
"silenceWarnings",
63+
"disallowDeprecations",
64+
"silenceDeprecations",
65+
"disallowInlining",
66+
"disallowOptimization",
67+
"requireBoundsCheck",
68+
"requireContracts",
69+
"relaxProperties",
70+
"noDefaultFlags"
71+
]
72+
},
73+
"minItems": 1,
74+
"uniqueItems": true,
75+
"description": "List of required settings for the build process"
76+
},
77+
"buildOptions": {
78+
"$ref": "#/definitions/buildOptions"
79+
},
80+
"libs": {
81+
"$ref": "#/definitions/stringArray",
82+
"description": "A list of external library names - depending on the compiler, these will be converted to the proper linker flag (e.g. \"ssl\" might get translated to \"-L-lssl\")"
83+
},
84+
"sourceFiles": {
85+
"$ref": "#/definitions/stringArray",
86+
"description": "Additional files passed to the compiler - can be useful to add certain configuration dependent source files that are not contained in the general source folder"
87+
},
88+
"sourcePaths": {
89+
"$ref": "#/definitions/stringArray",
90+
"description": "Allows to customize the path where to look for source files (any folder \"source\" or \"src\" is automatically used as a source path if no sourcePaths setting is specified) - note that you usually also need to define \"importPaths\" as \"sourcePaths\" don't influence those"
91+
},
92+
"excludedSourceFiles": {
93+
"$ref": "#/definitions/stringArray",
94+
"description": "Files that should be removed for the set of already added source files (takes precedence over \"sourceFiles\" and \"sourcePaths\") - Glob matching can be used to pattern match multiple files at once"
95+
},
96+
"mainSourceFile": {
97+
"type": "string",
98+
"description": "Determines the file that contains the main() function. This setting can be used by dub to exclude this file in situations where a different main function is defined (e.g. for \"dub test\")"
99+
},
100+
"copyFiles": {
101+
"$ref": "#/definitions/stringArray",
102+
"description": "A list of globs matching files or directories to be copied to targetPath. Matching directories are copied recursively, i.e. \"copyFiles\": [\"path/to/dir\"]\" recursively copies dir, while \"copyFiles\": [\"path/to/dir/*\"]\" only copies files within dir."
103+
},
104+
"versions": {
105+
"$ref": "#/definitions/stringArray",
106+
"description": "A list of D versions to be defined during compilation"
107+
},
108+
"debugVersions": {
109+
"$ref": "#/definitions/stringArray",
110+
"description": "A list of D debug identifiers to be defined during compilation"
111+
},
112+
"importPaths": {
113+
"$ref": "#/definitions/stringArray",
114+
"description": "Additional import paths to search for D modules (the source/ folder is used by default as a source folder, if it exists)",
115+
"default": [
116+
"source"
117+
]
118+
},
119+
"stringImportPaths": {
120+
"$ref": "#/definitions/stringArray",
121+
"description": "Additional import paths to search for string imports/views (the views/ folder is used by default as a string import folder, if it exists)",
122+
"default": [
123+
"views"
124+
]
125+
},
126+
"preGenerateCommands": {
127+
"$ref": "#/definitions/stringArray",
128+
"description": "A list of shell commands that is executed before project generation is started"
129+
},
130+
"postGenerateCommands": {
131+
"$ref": "#/definitions/stringArray",
132+
"description": "A list of shell commands that is executed after project generation is finished"
133+
},
134+
"preBuildCommands": {
135+
"$ref": "#/definitions/stringArray",
136+
"description": "A list of shell commands that is executed always before the project is built"
137+
},
138+
"postBuildCommands": {
139+
"$ref": "#/definitions/stringArray",
140+
"description": "A list of shell commands that is executed always after the project is built"
141+
},
142+
"dflags": {
143+
"$ref": "#/definitions/stringArray",
144+
"description": "Additional flags passed to the D compiler - note that these flags are usually specific to the compiler in use, but a set of flags is automatically translated from DMD to the selected compiler"
145+
},
146+
"lflags": {
147+
"$ref": "#/definitions/stringArray",
148+
"description": "Additional flags passed to the linker - note that these flags are usually specific to the linker in use"
149+
}
150+
}
151+
},
152+
"buildSettings": {
153+
"allOf": [
154+
{
155+
"$ref": "#/definitions/lowBuildSettings"
156+
},
157+
{
158+
"properties": {
159+
"dependencies": {
160+
"type": "object",
161+
"additionalProperties": {
162+
"oneOf": [
163+
{
164+
"type": "string"
165+
},
166+
{
167+
"type": "object",
168+
"properties": {
169+
"optional": {
170+
"type": "boolean",
171+
"description": "Indicate an optional dependency"
172+
},
173+
"version": {
174+
"type": "string",
175+
"description": "The version specification as used for the simple form"
176+
},
177+
"path": {
178+
"type": "string",
179+
"description": "Use a folder to source a package from"
180+
}
181+
}
182+
}
183+
]
184+
},
185+
"description": "List of project dependencies given as pairs of \"<name>\" : <version-spec>"
186+
},
187+
"targetType": {
188+
"type": "string",
189+
"default": "autodetect",
190+
"enum": [
191+
"autodetect",
192+
"none",
193+
"executable",
194+
"library",
195+
"sourceLibrary",
196+
"staticLibrary",
197+
"dynamicLibrary"
198+
],
199+
"description": "Specifies a specific target type"
200+
},
201+
"targetName": {
202+
"type": "string",
203+
"description": "Sets the base name of the output file; type and platform specific pre- and suffixes are added automatically"
204+
},
205+
"targetPath": {
206+
"type": "string",
207+
"description": "The destination path of the output binary"
208+
},
209+
"workingDirectory": {
210+
"type": "string",
211+
"description": "A fixed working directory from which the generated executable will be run"
212+
},
213+
"subConfigurations": {
214+
"type": "object",
215+
"additionalProperties": {
216+
"$ref": "#/definitions/packageName"
217+
},
218+
"description": "Locks the dependencies to specific configurations; a map from package name to configuration name"
219+
}
220+
}
221+
}
222+
]
223+
}
224+
},
225+
"allOf": [
226+
{
227+
"$ref": "#/definitions/buildSettings"
228+
},
229+
{
230+
"properties": {
231+
"name": {
232+
"$ref": "#/definitions/packageName",
233+
"description": "Name of the package, used to uniquely identify the package. Must be comprised of only lower case ASCII alpha-numeric characters, \"-\" or \"_\"."
234+
},
235+
"description": {
236+
"type": "string",
237+
"description": "Brief description of the package"
238+
},
239+
"homepage": {
240+
"type": "string",
241+
"format": "uri",
242+
"description": "URL of the project website"
243+
},
244+
"authors": {
245+
"$ref": "#/definitions/stringArray",
246+
"description": "List of project authors"
247+
},
248+
"copyright": {
249+
"type": "string",
250+
"description": "Copyright declaration string"
251+
},
252+
"license": {
253+
"type": "string",
254+
"enum": [
255+
"public domain",
256+
"AFL-3.0",
257+
"AGPL-3.0",
258+
"Apache-2.0",
259+
"APSL-2.0",
260+
"Artistic-2.0",
261+
"BSL-1.0",
262+
"BSD 2-clause",
263+
"BSD 3-clause",
264+
"EPL-1.0",
265+
"GPL-2.0",
266+
"GPL-3.0",
267+
"ISC",
268+
"LGPL-2.1",
269+
"LGPL-3.0",
270+
"MIT",
271+
"MPL-2.0",
272+
"MS-PL",
273+
"MS-RL",
274+
"OpenSSL",
275+
"SSLeay",
276+
"Zlib"
277+
],
278+
"pattern": ".*",
279+
"description": "License(s) under which the project can be used"
280+
},
281+
"subPackages": {
282+
"type": "array",
283+
"description": "Defines an array of sub-packages defined in the same directory as the root project, where each entry is either a path of a sub folder or an object of the same format as a dub.json file",
284+
"items": {
285+
"oneOf": [
286+
{
287+
"type": "string",
288+
"description": "Path to package folder"
289+
},
290+
{
291+
"$ref": "#"
292+
}
293+
]
294+
}
295+
},
296+
"configurations": {
297+
"type": "array",
298+
"items": {
299+
"allOf": [
300+
{
301+
"properties": {
302+
"name": {
303+
"$ref": "#/definitions/packageName",
304+
"description": "Name of the package, used to uniquely identify the package. Must be comprised of only lower case ASCII alpha-numeric characters, \"-\" or \"_\"."
305+
}
306+
}
307+
},
308+
{
309+
"$ref": "#/definitions/buildSettings"
310+
}
311+
]
312+
},
313+
"description": "Speficies an optional list of build configurations (chosen on the command line using --config=...)"
314+
},
315+
"buildTypes": {
316+
"type": "object",
317+
"description": "Defines additional custom build types or overrides the default ones (chosen on the command line using --build=...)",
318+
"additionalProperties": {
319+
"$ref": "#/definitions/lowBuildSettings"
320+
}
321+
}
322+
}
323+
}
324+
],
325+
"required": [
326+
"name"
327+
]
328+
}

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,12 @@
9292
"command": "code-d.switchConfiguration",
9393
"title": "code-d: Switch Configuration"
9494
}
95+
],
96+
"jsonValidation": [
97+
{
98+
"fileMatch": "dub.json",
99+
"url": "./json-validation/dub.schema.json"
100+
}
95101
]
96102
},
97103
"scripts": {

0 commit comments

Comments
 (0)