UNPKG

4.54 kBJSONView Raw
1{
2 "title": "CodeChunk",
3 "@id": "stencila:CodeChunk",
4 "extends": "CodeExecutable",
5 "category": "code",
6 "role": "secondary",
7 "status": "unstable",
8 "description": "A executable chunk of code.",
9 "properties": {
10 "type": {
11 "@id": "schema:type",
12 "description": "The name of the type.",
13 "type": "string",
14 "enum": [
15 "CodeChunk"
16 ],
17 "default": "CodeChunk",
18 "from": "Entity"
19 },
20 "id": {
21 "@id": "schema:id",
22 "description": "The identifier for this item.",
23 "type": "string",
24 "from": "Entity"
25 },
26 "meta": {
27 "@id": "stencila:meta",
28 "description": "Metadata associated with this item.",
29 "type": "object",
30 "from": "Entity"
31 },
32 "text": {
33 "@id": "schema:text",
34 "description": "The text of the code.",
35 "type": "string",
36 "from": "Code"
37 },
38 "programmingLanguage": {
39 "@id": "schema:programmingLanguage",
40 "description": "The programming language of the code.",
41 "type": "string",
42 "from": "Code",
43 "isOverride": true
44 },
45 "mediaType": {
46 "@id": "schema:encodingFormat",
47 "aliases": [
48 "encodingFormat"
49 ],
50 "description": "Media type, typically expressed using a MIME format, of the code.",
51 "$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",
52 "type": "string",
53 "from": "Code"
54 },
55 "compileDigest": {
56 "@id": "stencila:compileDigest",
57 "description": "The SHA-256 digest of the `text`, `programmingLanguage` and `mediaType` properties the last time the node was compiled.",
58 "type": "string",
59 "$comment": "Used to determine whether it is necessary to re-compile the node (i.e. to semantically analyse it\nfor dependencies).\n",
60 "from": "CodeExecutable"
61 },
62 "executeDigest": {
63 "@id": "stencila:executeDigest",
64 "description": "The SHA-256 digest of `compileDigest` and the `executeDigest`s of all dependencies, the last time the node was executed.",
65 "type": "string",
66 "$comment": "Used to determine whether it is necessary to re-execute the code.\n",
67 "from": "CodeExecutable"
68 },
69 "errors": {
70 "@id": "stencila:errors",
71 "description": "Errors when compiling (e.g. syntax errors) or executing the chunk.",
72 "type": "array",
73 "items": {
74 "$ref": "CodeError.schema.json"
75 },
76 "from": "CodeExecutable",
77 "isArray": true,
78 "isPlural": true,
79 "aliases": [
80 "error"
81 ]
82 },
83 "duration": {
84 "@id": "stencila:duration",
85 "description": "Duration in seconds of the last execution of the code.",
86 "type": "number",
87 "minimum": 0,
88 "from": "CodeExecutable"
89 },
90 "label": {
91 "@id": "stencila:label",
92 "description": "A short label for the CodeChunk.",
93 "type": "string",
94 "from": "CodeChunk"
95 },
96 "caption": {
97 "@id": "schema:caption",
98 "description": "A caption for the CodeChunk.",
99 "$comment": "An array of nodes or, to be compatible with https://schema.org/caption, a string.\n",
100 "anyOf": [
101 {
102 "type": "array",
103 "items": {
104 "$ref": "BlockContent.schema.json"
105 }
106 },
107 {
108 "type": "string"
109 }
110 ],
111 "from": "CodeChunk"
112 },
113 "outputs": {
114 "@id": "stencila:outputs",
115 "description": "Outputs from executing the chunk.",
116 "type": "array",
117 "items": {
118 "$ref": "Node.schema.json"
119 },
120 "from": "CodeChunk",
121 "isArray": true,
122 "isPlural": true,
123 "aliases": [
124 "output"
125 ]
126 }
127 },
128 "examples": [
129 {
130 "type": "CodeChunk",
131 "programmingLanguage": "python",
132 "text": "print('Hello world!')"
133 }
134 ],
135 "file": "CodeChunk.schema.yaml",
136 "children": [],
137 "descendants": [],
138 "$schema": "http://json-schema.org/draft-07/schema#",
139 "$id": "https://schema.stenci.la/v1/CodeChunk.schema.json",
140 "source": "https://github.com/stencila/schema/blob/master/schema/CodeChunk.schema.yaml",
141 "type": "object",
142 "propertyAliases": {
143 "encodingFormat": "mediaType",
144 "error": "errors",
145 "output": "outputs"
146 },
147 "additionalProperties": false,
148 "required": [
149 "type",
150 "text",
151 "programmingLanguage"
152 ]
153}