Skip to content

Commit

Permalink
Added auto completion to dub.json
Browse files Browse the repository at this point in the history
  • Loading branch information
WebFreak001 committed Jan 2, 2016
1 parent d5eb32b commit 8542c37
Show file tree
Hide file tree
Showing 2 changed files with 334 additions and 0 deletions.
328 changes: 328 additions & 0 deletions json-validation/dub.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,328 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "dub Package Schema",
"type": "object",
"definitions": {
"packageName": {
"type": "string",
"pattern": "^[-a-z0-9_]+$"
},
"stringArray": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1,
"uniqueItems": true
},
"buildOptions": {
"type": "array",
"items": {
"type": "string",
"enum": [
"debugMode",
"releaseMode",
"coverage",
"debugInfo",
"debugInfoC",
"alwaysStackFrame",
"stackStomping",
"inline",
"noBoundsCheck",
"optimize",
"profile",
"unittests",
"verbose",
"ignoreUnknownPragmas",
"syntaxOnly",
"warnings",
"warningsAsErrors",
"ignoreDeprecations",
"deprecationWarnings",
"deprecationErrors",
"property"
]
},
"minItems": 1,
"uniqueItems": true,
"description": "List of build option identifiers (corresponding to compiler flags)"
},
"lowBuildSettings": {
"properties": {
"systemDependencies": {
"type": "string",
"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"
},
"buildRequirements": {
"type": "array",
"items": {
"type": "string",
"enum": [
"allowWarnings",
"silenceWarnings",
"disallowDeprecations",
"silenceDeprecations",
"disallowInlining",
"disallowOptimization",
"requireBoundsCheck",
"requireContracts",
"relaxProperties",
"noDefaultFlags"
]
},
"minItems": 1,
"uniqueItems": true,
"description": "List of required settings for the build process"
},
"buildOptions": {
"$ref": "#/definitions/buildOptions"
},
"libs": {
"$ref": "#/definitions/stringArray",
"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\")"
},
"sourceFiles": {
"$ref": "#/definitions/stringArray",
"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"
},
"sourcePaths": {
"$ref": "#/definitions/stringArray",
"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"
},
"excludedSourceFiles": {
"$ref": "#/definitions/stringArray",
"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"
},
"mainSourceFile": {
"type": "string",
"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\")"
},
"copyFiles": {
"$ref": "#/definitions/stringArray",
"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."
},
"versions": {
"$ref": "#/definitions/stringArray",
"description": "A list of D versions to be defined during compilation"
},
"debugVersions": {
"$ref": "#/definitions/stringArray",
"description": "A list of D debug identifiers to be defined during compilation"
},
"importPaths": {
"$ref": "#/definitions/stringArray",
"description": "Additional import paths to search for D modules (the source/ folder is used by default as a source folder, if it exists)",
"default": [
"source"
]
},
"stringImportPaths": {
"$ref": "#/definitions/stringArray",
"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)",
"default": [
"views"
]
},
"preGenerateCommands": {
"$ref": "#/definitions/stringArray",
"description": "A list of shell commands that is executed before project generation is started"
},
"postGenerateCommands": {
"$ref": "#/definitions/stringArray",
"description": "A list of shell commands that is executed after project generation is finished"
},
"preBuildCommands": {
"$ref": "#/definitions/stringArray",
"description": "A list of shell commands that is executed always before the project is built"
},
"postBuildCommands": {
"$ref": "#/definitions/stringArray",
"description": "A list of shell commands that is executed always after the project is built"
},
"dflags": {
"$ref": "#/definitions/stringArray",
"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"
},
"lflags": {
"$ref": "#/definitions/stringArray",
"description": "Additional flags passed to the linker - note that these flags are usually specific to the linker in use"
}
}
},
"buildSettings": {
"allOf": [
{
"$ref": "#/definitions/lowBuildSettings"
},
{
"properties": {
"dependencies": {
"type": "object",
"additionalProperties": {
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"properties": {
"optional": {
"type": "boolean",
"description": "Indicate an optional dependency"
},
"version": {
"type": "string",
"description": "The version specification as used for the simple form"
},
"path": {
"type": "string",
"description": "Use a folder to source a package from"
}
}
}
]
},
"description": "List of project dependencies given as pairs of \"<name>\" : <version-spec>"
},
"targetType": {
"type": "string",
"default": "autodetect",
"enum": [
"autodetect",
"none",
"executable",
"library",
"sourceLibrary",
"staticLibrary",
"dynamicLibrary"
],
"description": "Specifies a specific target type"
},
"targetName": {
"type": "string",
"description": "Sets the base name of the output file; type and platform specific pre- and suffixes are added automatically"
},
"targetPath": {
"type": "string",
"description": "The destination path of the output binary"
},
"workingDirectory": {
"type": "string",
"description": "A fixed working directory from which the generated executable will be run"
},
"subConfigurations": {
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/packageName"
},
"description": "Locks the dependencies to specific configurations; a map from package name to configuration name"
}
}
}
]
}
},
"allOf": [
{
"$ref": "#/definitions/buildSettings"
},
{
"properties": {
"name": {
"$ref": "#/definitions/packageName",
"description": "Name of the package, used to uniquely identify the package. Must be comprised of only lower case ASCII alpha-numeric characters, \"-\" or \"_\"."
},
"description": {
"type": "string",
"description": "Brief description of the package"
},
"homepage": {
"type": "string",
"format": "uri",
"description": "URL of the project website"
},
"authors": {
"$ref": "#/definitions/stringArray",
"description": "List of project authors"
},
"copyright": {
"type": "string",
"description": "Copyright declaration string"
},
"license": {
"type": "string",
"enum": [
"public domain",
"AFL-3.0",
"AGPL-3.0",
"Apache-2.0",
"APSL-2.0",
"Artistic-2.0",
"BSL-1.0",
"BSD 2-clause",
"BSD 3-clause",
"EPL-1.0",
"GPL-2.0",
"GPL-3.0",
"ISC",
"LGPL-2.1",
"LGPL-3.0",
"MIT",
"MPL-2.0",
"MS-PL",
"MS-RL",
"OpenSSL",
"SSLeay",
"Zlib"
],
"pattern": ".*",
"description": "License(s) under which the project can be used"
},
"subPackages": {
"type": "array",
"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",
"items": {
"oneOf": [
{
"type": "string",
"description": "Path to package folder"
},
{
"$ref": "#"
}
]
}
},
"configurations": {
"type": "array",
"items": {
"allOf": [
{
"properties": {
"name": {
"$ref": "#/definitions/packageName",
"description": "Name of the package, used to uniquely identify the package. Must be comprised of only lower case ASCII alpha-numeric characters, \"-\" or \"_\"."
}
}
},
{
"$ref": "#/definitions/buildSettings"
}
]
},
"description": "Speficies an optional list of build configurations (chosen on the command line using --config=...)"
},
"buildTypes": {
"type": "object",
"description": "Defines additional custom build types or overrides the default ones (chosen on the command line using --build=...)",
"additionalProperties": {
"$ref": "#/definitions/lowBuildSettings"
}
}
}
}
],
"required": [
"name"
]
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@
"command": "code-d.switchConfiguration",
"title": "code-d: Switch Configuration"
}
],
"jsonValidation": [
{
"fileMatch": "dub.json",
"url": "./json-validation/dub.schema.json"
}
]
},
"scripts": {
Expand Down

0 comments on commit 8542c37

Please sign in to comment.