UNPKG

8.87 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 "codeDependencies": {
56 "@id": "stencila:codeDependencies",
57 "description": "The upstream dependencies of the code.",
58 "type": "array",
59 "items": {
60 "anyOf": [
61 {
62 "$ref": "CodeChunk.schema.json"
63 },
64 {
65 "$ref": "Parameter.schema.json"
66 }
67 ]
68 },
69 "$comment": "Note that this excludes `CodeExpression` nodes since they should not have side effects\n(e.g. assigning variables) that would cause another node to be dependent upon them.\n",
70 "from": "CodeExecutable",
71 "isArray": true,
72 "isPlural": true,
73 "aliases": [
74 "codeDependencie"
75 ]
76 },
77 "codeDependents": {
78 "@id": "stencila:codeDependents",
79 "description": "The downstream dependents of the code.",
80 "type": "array",
81 "items": {
82 "anyOf": [
83 {
84 "$ref": "CodeChunk.schema.json"
85 },
86 {
87 "$ref": "CodeExpression.schema.json"
88 }
89 ]
90 },
91 "$comment": "Note that in comparison to `codeDependencies`, this property does not allow for `Parameter`\ndependents (because parameters are never dependent upon others).\n",
92 "from": "CodeExecutable",
93 "isArray": true,
94 "isPlural": true,
95 "aliases": [
96 "codeDependent"
97 ]
98 },
99 "compileDigest": {
100 "@id": "stencila:compileDigest",
101 "description": "A digest of the content, semantics and dependencies of the node.",
102 "type": "string",
103 "from": "CodeExecutable"
104 },
105 "executeCount": {
106 "@id": "stencila:executeCount",
107 "description": "A count of the number of times that the node has been executed.",
108 "type": "integer",
109 "minimum": 0,
110 "$comment": "Intended to increment with each successive execution of the node, including across sessions.\nNote that this differs to the `execution_count` in Jupyter Notebook format which is\nthe \"code cell's prompt number\" and which resets at the start of each new session.\n",
111 "from": "CodeExecutable"
112 },
113 "executeDigest": {
114 "@id": "stencila:executeDigest",
115 "description": "The `compileDigest` of the node when it was last executed.",
116 "type": "string",
117 "from": "CodeExecutable"
118 },
119 "executeRequired": {
120 "@id": "stencila:executeRequired",
121 "description": "Whether, and why, a node requires execution or re-execution.",
122 "enum": [
123 "No",
124 "NeverExecuted",
125 "SemanticsChanged",
126 "DependenciesChanged",
127 "DependenciesFailed"
128 ],
129 "$comment": "Derived from a comparison of `compileDigest` and `executeDigest` and the `executeStatus`\nof dependencies.\n`No`: no re-execution is required, the semantics of the code and its dependencies has not changed\nsince it was last executed.\n`NeverExecuted`: execution is required because the code has never been executed (or any previous\nexecution was not persisted in its state).\n`SemanticsChanged`: re-execution is required because the semantics of the code has changed since it was\nlast executed.\n`DependenciesChanged`: the semantics of one or more dependencies (including transitive dependencies) \nchanged since it was last executed.\n`DependenciesFailed`: one or more dependencies (including transitive dependencies) failed when it was\nlast executed.\n",
130 "from": "CodeExecutable"
131 },
132 "executeStatus": {
133 "@id": "stencila:executeStatus",
134 "description": "Status of the most recent, including any current, execution of the code.",
135 "enum": [
136 "Scheduled",
137 "ScheduledPreviouslyFailed",
138 "Running",
139 "RunningPreviouslyFailed",
140 "Succeeded",
141 "Failed",
142 "Cancelled"
143 ],
144 "from": "CodeExecutable"
145 },
146 "executeEnded": {
147 "@id": "stencila:executeEnded",
148 "description": "The date-time that the the last execution of the code ended.",
149 "$ref": "Date.schema.json",
150 "from": "CodeExecutable"
151 },
152 "executeDuration": {
153 "@id": "stencila:executeDuration",
154 "description": "Duration in seconds of the last execution of the code.",
155 "type": "number",
156 "minimum": 0,
157 "from": "CodeExecutable"
158 },
159 "errors": {
160 "@id": "stencila:errors",
161 "description": "Errors when compiling (e.g. syntax errors) or executing the chunk.",
162 "type": "array",
163 "items": {
164 "$ref": "CodeError.schema.json"
165 },
166 "from": "CodeExecutable",
167 "isArray": true,
168 "isPlural": true,
169 "aliases": [
170 "error"
171 ]
172 },
173 "label": {
174 "@id": "stencila:label",
175 "description": "A short label for the CodeChunk.",
176 "type": "string",
177 "from": "CodeChunk"
178 },
179 "caption": {
180 "@id": "schema:caption",
181 "description": "A caption for the CodeChunk.",
182 "$comment": "An array of nodes or, to be compatible with https://schema.org/caption, a string.\n",
183 "anyOf": [
184 {
185 "type": "array",
186 "items": {
187 "$ref": "BlockContent.schema.json"
188 }
189 },
190 {
191 "type": "string"
192 }
193 ],
194 "from": "CodeChunk"
195 },
196 "executeAuto": {
197 "@id": "stencila:executeAuto",
198 "description": "Under which circumstances the node should be automatically executed.",
199 "enum": [
200 "Never",
201 "Needed",
202 "Always"
203 ],
204 "default": "Needed",
205 "$comment": "`Never`: Never automatically execute the code chunk. Only execute when the user explicitly runs\nthe code (or its containing document).\n`Needed`: Automatically execute the code chunk if needed. Execute the code chunk if it is an \nupstream dependency of a node that has been executed, or is a downstream dependent of a node that\nhas been executed.\n`Always`: Always execute the code, even if it, or its dependencies, are unchanged since the \nlast time it was executed.\n",
206 "from": "CodeChunk"
207 },
208 "executePure": {
209 "@id": "stencila:executePure",
210 "description": "Whether the code should be treated as side-effect free when executed.",
211 "type": "boolean",
212 "from": "CodeChunk"
213 },
214 "outputs": {
215 "@id": "stencila:outputs",
216 "description": "Outputs from executing the chunk.",
217 "type": "array",
218 "items": {
219 "$ref": "Node.schema.json"
220 },
221 "from": "CodeChunk",
222 "isArray": true,
223 "isPlural": true,
224 "aliases": [
225 "output"
226 ]
227 }
228 },
229 "examples": [
230 {
231 "type": "CodeChunk",
232 "programmingLanguage": "python",
233 "text": "print('Hello world!')"
234 }
235 ],
236 "file": "CodeChunk.schema.yaml",
237 "children": [],
238 "descendants": [],
239 "$schema": "http://json-schema.org/draft-07/schema#",
240 "$id": "https://schema.stenci.la/v1/CodeChunk.schema.json",
241 "source": "https://github.com/stencila/schema/blob/master/schema/CodeChunk.schema.yaml",
242 "type": "object",
243 "propertyAliases": {
244 "encodingFormat": "mediaType",
245 "codeDependencie": "codeDependencies",
246 "codeDependent": "codeDependents",
247 "error": "errors",
248 "output": "outputs"
249 },
250 "additionalProperties": false,
251 "required": [
252 "type",
253 "text",
254 "programmingLanguage"
255 ]
256}