@stencila/schema
Version:
Extensions to schema.org to support semantic, composable, parameterize-able and executable documents
87 lines (86 loc) • 2.63 kB
JSON
{
"title": "Code",
"@id": "stencila:Code",
"extends": "Entity",
"role": "base",
"status": "stable",
"category": "code",
"description": "Base type for non-executable (e.g. `CodeBlock`) and executable (e.g. `CodeExpression`) code nodes.",
"$comment": "The most important, and only required, property of a `Code` node is `text`, a `string` of the source code.\nThere are no restrictions on the length or content of `text` and it is possible for it to be syntactically\ninvalid for the specified `programmingLanguage`.\n",
"properties": {
"type": {
"@id": "schema:type",
"description": "The name of the type.",
"type": "string",
"enum": [
"Code",
"CodeBlock",
"CodeChunk",
"CodeExecutable",
"CodeExpression",
"CodeFragment"
],
"default": "Code",
"from": "Entity"
},
"id": {
"@id": "schema:id",
"description": "The identifier for this item.",
"type": "string",
"from": "Entity"
},
"meta": {
"@id": "stencila:meta",
"description": "Metadata associated with this item.",
"type": "object",
"from": "Entity"
},
"text": {
"@id": "schema:text",
"description": "The text of the code.",
"type": "string",
"from": "Code"
},
"programmingLanguage": {
"@id": "schema:programmingLanguage",
"description": "The programming language of the code.",
"type": "string",
"from": "Code"
},
"mediaType": {
"@id": "schema:encodingFormat",
"aliases": [
"encodingFormat"
],
"description": "Media type, typically expressed using a MIME format, of the code.",
"$comment": "This property allows the differentiation of formats using the same programming language\nor variants of a programming language. An example is using `programmingLanguage` \"json\" and\n`encodingFormat` \"application/ld+json\" for JSON-LD code examples.\n",
"type": "string",
"from": "Code"
}
},
"required": [
"type",
"text"
],
"file": "Code.schema.yaml",
"children": [
"CodeBlock",
"CodeExecutable",
"CodeFragment"
],
"descendants": [
"CodeBlock",
"CodeChunk",
"CodeExecutable",
"CodeExpression",
"CodeFragment"
],
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://schema.stenci.la/v1/Code.schema.json",
"source": "https://github.com/stencila/schema/blob/master/schema/Code.schema.yaml",
"type": "object",
"propertyAliases": {
"encodingFormat": "mediaType"
},
"additionalProperties": false
}