Skip to content

Commit

Permalink
Various schema improvements
Browse files Browse the repository at this point in the history
 - Add $schema to all schemas and unify whitespace
 - Remove `additionalProperties: false` from sublime-project schema because:
   a) we don't actually want to limit keys to only known names
   b) it was defined in the wrong spot so it didn't function as one would
      expect (it was just an extra property called literally `additionalProperties`).
 - Add enum descriptions in sublime-settings schema
 - Use markdown for rendering descriptions
 - Added schema definitions created by AmjadHD
   Original schemas from https://github.com/AmjadHD/sublime_json_schemas
 - Fix multiple items in context triggering a warning
   If there was more than one object in context array, and those didn't
   follow the same schema then warning was triggered.
  • Loading branch information
rchl committed Mar 21, 2020
1 parent 59f4811 commit 3617e0d
Show file tree
Hide file tree
Showing 15 changed files with 1,082 additions and 30 deletions.
17 changes: 9 additions & 8 deletions schemas/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"allowComments": true,
"allowTrailingCommas": true,
"title": "JSON schema for the JavaScript configuration file",
"type": "object",
"default": {
"compilerOptions": {
"target": "es6"
}
"$schema": "http://json-schema.org/draft-07/schema#",
"allowComments": true,
"allowTrailingCommas": true,
"title": "JSON schema for the JavaScript configuration file",
"type": "object",
"default": {
"compilerOptions": {
"target": "es6"
}
}
}
12 changes: 6 additions & 6 deletions schemas/package-json-eslint.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"eslintConfig": {
"description": "ESLint configuration",
"$ref": "http://json.schemastore.org/eslintrc"
}
"$schema": "http://json-schema.org/draft-07/schema",
"properties": {
"eslintConfig": {
"description": "ESLint configuration",
"$ref": "http://json.schemastore.org/eslintrc"
}
}
}
117 changes: 116 additions & 1 deletion schemas/sublime-build.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,122 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-build",
"title": "Sublime Text Build System",
"allowComments": true,
"allowTrailingCommas": true,
"type": "object"
"type": "object",
"properties": {
"selector": {
"type": "string",
"markdownDescription": "The base scope name of the syntax that this build system should be enabled for."
},
"file_patterns": {
"markdownDescription": "A list of file name patterns the build system should be enabled for.",
"type": "array",
"items": {
"type": "string"
}
},
"keyfiles": {
"markdownDescription": "A list of file names, if present in one of the opened folders, that will cause the build system to be enabled.",
"type": "array",
"items": {
"type": "string"
}
},
"variants": {
"markdownDescription": "A list of subsidiary build systems that will inherit the options from the top-level build system. Each variant needs to specify a `name` key, and may override or add options to the top-level build system",
"type": "array",
"items": {
"allOf": [
{"$ref": "#"},
{ "properties": {
"name": {
"type": "string"
}
},
"required": ["name"]
}
]
}
},
"cancel": {
"markdownDescription": "A string command name, or an object of string options. If a string is specified, the command specified will be used to cancel the build. If an object, the primary target will be called, with these options added on. This only needs to be specified when using a custom `target`.",
"type": ["string", "object"]
},
"target": {
"markdownDescription": "The command to run when the build system is invoked. The default value of exec allows use of the additional options specified in [exec Target Options](https://www.sublimetext.com/docs/3/build_systems.html#exec_options). If a value other than `exec` is specified, none of the options in exec Target Options will do anything. See the [Advanced Example](https://www.sublimetext.com/docs/3/build_systems.html#advanced_example) for a complete example.",
"type": "string"
},
"windows": {
"allOf": [
{"$ref": "#"},
{
"markdownDescription": "An object of options to use when the build system is being executed on a Windows machine.\nExample:\n```\n{\n\t\"cmd\": [\"my_command.exe\", \"/D\", \"$file\"]\n}\n```"
}
]
},
"osx": {
"allOf": [
{"$ref": "#"},
{
"markdownDescription": "An object of options to use when the build system is being executed on a Mac machine.\nExample:\n```\n{\n\t\"cmd\": [\"/Applications/MyProgram.app/Contents/MacOS/my_command\", \"-d\", \"$file\"]\n}"
}
]
},
"linux": {
"allOf": [
{"$ref": "#"},
{
"markdownDescription": "An object of options to use when the build system is being executed on a Linux machine.\nExample:\n```\n{\n\t\"cmd\": [\"/usr/local/bin/my_command\", \"-d\", \"$file\"]\n}"
}
]
},
"cmd": {
"markdownDescription": "A list of strings specifying the executable to run, plus any arguments to pass to it. Shell constructs such as piping and redirection are not supported – see [shell_cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-shell_cmd). May use [variables](https://www.sublimetext.com/docs/3/build_systems.html#variables).",
"type": "array",
"items": {
"type": "string"
}
},
"shell_cmd": {
"markdownDescription": "A string specifying a shell command to execute. Unlike the [cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-cmd) option, this does allow piping and redirection. Will use `bash` on Mac and Linux machine, and `cmd.exe` on Windows. May use [variables](https://www.sublimetext.com/docs/3/build_systems.html#variables).\nExample: `\"my_command \\\"$file\\\" | other_command\"`",
"type": "string"
},
"working_dir": {
"markdownDescription": "A string specifying the directory to execute the [cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-cmd) or [shell_cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-shell_cmd) within. May use [variables](https://www.sublimetext.com/docs/3/build_systems.html#variables).\nExample: `\"$file_path\"`",
"type": "string"
},
"file_regex": {
"markdownDescription": "A string containing a regular expression to run on the build output to match file information. The matched file information is used to enable result navigation. The regex should capture 2, 3 or 4 groups.\n\nThe capture groups should be:\n\n1. filename\n2. line number\n3. column number\n4. message\n\nExample: `\"^\\s*(\\S[^:]*)\\((\\d+):(\\d+)\\): ([^\\n]+)\"`",
"type": "string",
"format": "regex"
},
"line_regex": {
"markdownDescription": "A string containing a regular expression to run on the build output to match line information. The matched file information is used to enable result navigation. The regex should capture 1, 2 or 3 groups.\n\nThe groups should capture:\n\n1.line number\n2. column number\n3. error message\n\nThis regular expression is only necessary when some results contain strictly a line number, line and column numbers, or line and column numbers with a message. When such a match is made, the [file_regex](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-file_regex) option will be used to search backwards to find the appropriate file name.\n\nExample: `\"^\\s*line (\\d+) col (\\d+): ([^\\n]+)\"",
"type": "string",
"format": "regex"
},
"encoding": {
"markdownDescription": "A string specifying the encoding of the build system output. Uses [Python codec names](https://docs.python.org/3.3/library/codecs.html#id3). Defaults to `\"utf-8\"`.\n\nExample: `\"iso-8859-1\"`",
"type": "string"
},
"env": {
"markdownDescription": "An object containing environment variable values to use when running the [cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-cmd) or [shell_cmd](https://www.sublimetext.com/docs/3/build_systems.html#exec_option-shell_cmd).\nExample:\n```\n{\n\t\"PYTHONIOENCODING\": \"utf-8\"\n}",
"type": "object"
},
"quiet": {
"markdownDescription": "A boolean that reduces the amount of output about the build system invocation.",
"type": "boolean"
},
"word_wrap": {
"markdownDescription": "A boolean that turns on word wrapping in the build system output panel.",
"type": "boolean"
},
"syntax": {
"markdownDescription": "A string specifying the syntax file to use to highlight the build system output panel.\nExample: `\"Packages/JavaScript/JSON.sublime-syntax\"`",
"type": "string",
"pattern": "^Packages/.+\\.(sublime-syntax|tmLanguage)"
}
}
}
1 change: 1 addition & 0 deletions schemas/sublime-color-scheme.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-color-scheme",
"title": "Sublime Text Color Scheme",
"allowComments": true,
Expand Down
1 change: 1 addition & 0 deletions schemas/sublime-commands.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-commands",
"title": "Sublime Text Commands",
"allowComments": true,
Expand Down
1 change: 1 addition & 0 deletions schemas/sublime-completions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-completions",
"title": "Sublime Text Completions",
"allowComments": true,
Expand Down
3 changes: 2 additions & 1 deletion schemas/sublime-keymap.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-keymap",
"title": "Sublime Text Keymap",
"allowComments": true,
Expand All @@ -20,7 +21,7 @@
"type": "object",
"properties": {
"key": {
"oneOf": [
"anyOf": [
{
"type": "string",
"description": "Condition that must evaluate to true for the key binding to be active",
Expand Down
1 change: 1 addition & 0 deletions schemas/sublime-macro.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-macro",
"title": "Sublime Text Macro",
"allowComments": true,
Expand Down
1 change: 1 addition & 0 deletions schemas/sublime-menu.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-menu",
"title": "Sublime Text Menu",
"allowComments": true,
Expand Down
1 change: 1 addition & 0 deletions schemas/sublime-mousemap.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-mousemap",
"title": "Sublime Text Mousemap",
"allowComments": true,
Expand Down
82 changes: 81 additions & 1 deletion schemas/sublime-project.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,87 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "sublime://sublime-project",
"title": "Sublime Text Project",
"allowComments": true,
"allowTrailingCommas": true,
"type": "object"
"type": "object",
"properties": {
"folders": {
"markdownDescription": "List of folders added to the project",
"type": "array",
"items": {
"type": "object",
"properties": {
"additionalProperties": false,
"path": {
"markdownDescription": "A path of a project folder.",
"type": "string"
},
"name": {
"markdownDescription": "A string used in place of the folder name in the side bar.",
"type": "string"
},
"file_include_patterns": {
"markdownDescription": "A list of filenames to include from the folder. Anything not matching these patterns will be excluded. This is checked before `file_exclude_patterns`.",
"type": "array",
"items": {
"type": "string"
}
},
"file_exclude_patterns": {
"markdownDescription": "A list of strings for filenames to exclude from the folder. This is added to the global setting of the same name. This is checked after `file_include_patterns`.",
"type": "array",
"items": {"type": "string", "examples": ["Hello", "World"]}
},
"folder_include_patterns": {
"markdownDescription": "A list of strings for subfolder paths to include from the folder. Anything not matching these patterns will be excluded. This is checked before `folder_exclude_patterns`.",
"type": "array",
"items": {"type": "string"}
},
"folder_exclude_patterns": {
"markdownDescription": "A list of strings for subfolder paths to exclude from the folder. This is added to the global setting of the same name. This is checked after `folder_include_patterns`.",
"type": "array",
"items": {"type": "string"}
},
"binary_file_patterns": {
"markdownDescription": "A list of strings for filenames to treat as binary files, and thus ignored in _Goto Anything_ or _Find in Files_.",
"type": "array",
"items": {"type": "string"}
},
"index_include_patterns": {
"markdownDescription": "A list of strings for full file paths to index in the folder. This is added to the global setting of the same name. Anything not matching these patterns will be excluded from the index. This is checked before `index_exclude_patterns`.",
"type": "array",
"items": {"type": "string"}
},
"index_exclude_patterns": {
"markdownDescription": "A list of strings for file full paths to index in the folder. This is added to the global setting of the same name. This is checked after `index_include_patterns`.",
"type": "array",
"items": {"type": "string"}
},
"follow_symlinks": {
"markdownDescription": "If symlinks should be followed when building the folder tree.",
"type": "boolean"
}
}
}
},
"settings": {
"type": "object"
},
"build_systems": {
"type": "array",
"items": {
"allOf": [
{"$ref": "sublime://sublime-build"},
{ "properties": {
"name": {
"type": "string"
}
},
"required": ["name"]
}
]
}
}
}
}
Loading

0 comments on commit 3617e0d

Please sign in to comment.