Skip to content

Commit

Permalink
Add schema and test
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Jun 4, 2020
1 parent 55229f3 commit 6771819
Show file tree
Hide file tree
Showing 10 changed files with 1,416 additions and 0 deletions.
14 changes: 14 additions & 0 deletions schema/annotation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Annotation associated to a declaration or a member: `%a{rbs:test}`, `%a{steep:deprecated}`, ...",
"type": "object",
"properties": {
"string": {
"type": "string"
},
"location": {
"$ref": "location.json"
}
},
"required": ["string", "location"]
}
26 changes: 26 additions & 0 deletions schema/comment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"comment": {
"type": "object",
"properties": {
"string": {
"type": "string"
},
"location": {
"$ref": "location.json"
}
},
"required": ["string", "location"]
}
},
"title": "Comment associated with a declaration or a member",
"oneOf": [
{
"$ref": "#/definitions/comment"
},
{
"type": "null"
}
]
}
327 changes: 327 additions & 0 deletions schema/decls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,327 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"alias": {
"title": "Type alias declaration: `type foo = Integer`, ...",
"type": "object",
"properties": {
"declaration": {
"type": "string",
"enum": ["alias"]
},
"name": {
"type": "string"
},
"type": {
"$ref": "types.json"
},
"annotations": {
"type": "array",
"items": {
"$ref": "annotation.json"
}
},
"location": {
"$ref": "location.json"
},
"comment": {
"$ref": "comment.json"
}
},
"required": ["declaration", "name", "type", "annotations", "location", "comment"]
},
"constant": {
"title": "Constant declaration: `VERSION: String`, ...",
"type": "object",
"properties": {
"declaration": {
"type": "string",
"enum": ["constant"]
},
"name": {
"type": "string"
},
"type": {
"$ref": "types.json"
},
"location": {
"$ref": "location.json"
},
"comment": {
"$ref": "comment.json"
}
},
"required": ["declaration", "name", "type", "comment", "location"]
},
"global": {
"title": "Global declaration: `$DEBUG: bool`, ...",
"type": "object",
"properties": {
"declaration": {
"type": "string",
"enum": ["global"]
},
"name": {
"type": "string"
},
"type": {
"$ref": "types.json"
},
"location": {
"$ref": "location.json"
},
"comment": {
"$ref": "comment.json"
}
},
"required": ["declaration", "name", "type", "comment", "location"]
},
"moduleTypeParam": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"variance": {
"enum": ["covariant", "contravariant", "invariant"]
},
"skip_validation": {
"type": "boolean"
}
},
"required": ["name", "variance", "skip_validation"]
},
"classMember": {
"oneOf": [
{
"$ref": "members.json#/definitions/methodDefinition"
},
{
"$ref": "members.json#/definitions/variable"
},
{
"$ref": "members.json#/definitions/include"
},
{
"$ref": "members.json#/definitions/extend"
},
{
"$ref": "members.json#/definitions/prepend"
},
{
"$ref": "members.json#/definitions/attribute"
},
{
"$ref": "members.json#/definitions/visibility"
},
{
"$ref": "members.json#/definitions/alias"
}
]
},
"class": {
"title": "Class declaration",
"type": "object",
"properties": {
"declaration": {
"enum": ["class"]
},
"name": {
"type": "string"
},
"type_params": {
"type": "object",
"properties": {
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/moduleTypeParam"
}
}
},
"required": ["params"]
},
"members": {
"type": "array",
"items": {
"$ref": "#/definitions/classMember"
}
},
"super_class": {
"oneOf": [
{
"type": "null"
},
{
"type": "object",
"properties": {
"name": {
"type": "string"
},
"args": {
"type": "array",
"items": {
"$ref": "types.json"
}
}
},
"required": ["name", "args"]
}
]
},
"annotations": {
"type": "array",
"items": {
"$ref": "annotation.json"
}
},
"comment": {
"$ref": "comment.json"
},
"location": {
"$ref": "location.json"
}
},
"required": ["declaration", "name", "type_params", "members", "super_class", "annotations", "comment", "location"]
},
"module": {
"type": "object",
"properties": {
"declaration": {
"enum": ["module"]
},
"name": {
"type": "string"
},
"type_params": {
"type": "object",
"properties": {
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/moduleTypeParam"
}
}
},
"required": ["params"]
},
"members": {
"type": "array",
"items": {
"$ref": "#/definitions/classMember"
}
},
"self_type": {
"oneOf": [
{
"$ref": "types.json"
},
{
"type": "null"
}
]
},
"annotations": {
"type": "array",
"items": {
"$ref": "annotation.json"
}
},
"comment": {
"$ref": "comment.json"
},
"location": {
"$ref": "location.json"
}
},
"required": ["declaration", "name", "type_params", "members", "self_type", "annotations", "location", "comment"]
},
"interfaceMember": {
"oneOf": [
{
"allOf": [
{
"$ref": "members.json#/definitions/methodDefinition"
},
{
"type": "object",
"properties": {
"kind": {
"enum": ["instance"]
}
}
}
]
},
{
"$ref": "members.json#/definitions/include"
},
{
"$ref": "members.json#/definitions/alias"
}
]
},
"interface": {
"type": "object",
"properties": {
"declaration": {
"enum": ["interface"]
},
"name": {
"type": "string"
},
"type_params": {
"type": "object",
"properties": {
"params": {
"type": "array",
"items": {
"$ref": "#/definitions/moduleTypeParam"
}
}
},
"required": ["params"]
},
"members": {
"type": "array",
"items": {
"$ref": "#/definitions/interfaceMember"
}
},
"annotations": {
"type": "array",
"items": {
"$ref": "annotation.json"
}
},
"comment": {
"$ref": "comment.json"
},
"location": {
"$ref": "location.json"
}
},
"required": ["declaration", "name", "type_params", "members", "annotations", "comment", "location"]
}
},
"oneOf": [
{
"$ref": "#/definitions/alias"
},
{
"$ref": "#/definitions/constant"
},
{
"$ref": "#/definitions/global"
},
{
"$ref": "#/definitions/class"
},
{
"$ref": "#/definitions/module"
},
{
"$ref": "#/definitions/interface"
}
]
}
Loading

0 comments on commit 6771819

Please sign in to comment.