1 | {
|
2 | "title": "CodeChunk",
|
3 | "@id": "stencila:CodeChunk",
|
4 | "extends": "CodeBlock",
|
5 | "role": "secondary",
|
6 | "status": "unstable",
|
7 | "category": "code",
|
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 | "programmingLanguage": {
|
33 | "@id": "schema:programmingLanguage",
|
34 | "description": "The programming language of the code.",
|
35 | "type": "string",
|
36 | "from": "Code"
|
37 | },
|
38 | "format": {
|
39 | "@id": "schema:encodingFormat",
|
40 | "aliases": [
|
41 | "encoding",
|
42 | "encodingFormat"
|
43 | ],
|
44 | "description": "Media type, typically expressed using a MIME format, of the code.",
|
45 | "$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",
|
46 | "type": "string",
|
47 | "from": "Code"
|
48 | },
|
49 | "text": {
|
50 | "@id": "schema:text",
|
51 | "description": "The text of the code.",
|
52 | "type": "string",
|
53 | "from": "Code"
|
54 | },
|
55 | "exportFrom": {
|
56 | "@id": "stencila:exportFrom",
|
57 | "aliases": [
|
58 | "export"
|
59 | ],
|
60 | "description": "A compilation directive giving the name of the variable to export\ninto the content of the code block.\n",
|
61 | "type": "string",
|
62 | "from": "CodeBlock"
|
63 | },
|
64 | "importTo": {
|
65 | "@id": "stencila:importTo",
|
66 | "aliases": [
|
67 | "export"
|
68 | ],
|
69 | "description": "A compilation directive giving the name of the variable to import\nthe content of the code block as.\n",
|
70 | "type": "string",
|
71 | "from": "CodeBlock"
|
72 | },
|
73 | "caption": {
|
74 | "@id": "schema:caption",
|
75 | "description": "A caption for the CodeChunk.",
|
76 | "$comment": "An array of nodes or, to be compatible with https://schema.org/caption,\na string.\n",
|
77 | "anyOf": [
|
78 | {
|
79 | "type": "string"
|
80 | },
|
81 | {
|
82 | "type": "array",
|
83 | "items": {
|
84 | "$ref": "Node.schema.json"
|
85 | }
|
86 | }
|
87 | ],
|
88 | "from": "CodeChunk"
|
89 | },
|
90 | "label": {
|
91 | "@id": "stencila:label",
|
92 | "description": "A short label for the CodeChunk.",
|
93 | "type": "string",
|
94 | "from": "CodeChunk"
|
95 | },
|
96 | "imports": {
|
97 | "@id": "stencila:imports",
|
98 | "description": "Software packages that the code chunk imports",
|
99 | "type": "array",
|
100 | "items": {
|
101 | "anyOf": [
|
102 | {
|
103 | "type": "string"
|
104 | },
|
105 | {
|
106 | "$ref": "SoftwareSourceCode.schema.json"
|
107 | },
|
108 | {
|
109 | "$ref": "SoftwareApplication.schema.json"
|
110 | }
|
111 | ]
|
112 | },
|
113 | "from": "CodeChunk",
|
114 | "isArray": true,
|
115 | "isPlural": true,
|
116 | "aliases": [
|
117 | "import"
|
118 | ]
|
119 | },
|
120 | "declares": {
|
121 | "@id": "stencila:declares",
|
122 | "description": "Variables that the code chunk declares.",
|
123 | "type": "array",
|
124 | "items": {
|
125 | "anyOf": [
|
126 | {
|
127 | "type": "string"
|
128 | },
|
129 | {
|
130 | "$ref": "Variable.schema.json"
|
131 | },
|
132 | {
|
133 | "$ref": "Function.schema.json"
|
134 | }
|
135 | ]
|
136 | },
|
137 | "from": "CodeChunk",
|
138 | "isArray": true,
|
139 | "isPlural": true,
|
140 | "aliases": [
|
141 | "declare"
|
142 | ]
|
143 | },
|
144 | "assigns": {
|
145 | "@id": "stencila:assigns",
|
146 | "description": "Variables that the code chunk assigns to.",
|
147 | "type": "array",
|
148 | "items": {
|
149 | "anyOf": [
|
150 | {
|
151 | "type": "string"
|
152 | },
|
153 | {
|
154 | "$ref": "Variable.schema.json"
|
155 | }
|
156 | ]
|
157 | },
|
158 | "$comment": "In languages such as Python and R we are unable\nto differentiate between an assignment that\nis a declaration and an assignment that is an alteration\n(a re-assignment).\nThe \"primary\" compiler keeps a track of the variables\ndeclared in code chunks prior to the current chunk in the\ndocument and may treat an assignment as a declaration.\n",
|
159 | "from": "CodeChunk",
|
160 | "isArray": true,
|
161 | "isPlural": true,
|
162 | "aliases": [
|
163 | "assign"
|
164 | ]
|
165 | },
|
166 | "alters": {
|
167 | "@id": "stencila:alters",
|
168 | "description": "Names of variables that the code chunk alters.",
|
169 | "type": "array",
|
170 | "items": {
|
171 | "type": "string"
|
172 | },
|
173 | "$comment": "This property allows users to add undetected\nalterations (i.e. not assignments) to this list. Chunks that alter a variable\nneed to be inserted into the dependency graph between `declares` and `uses`\n",
|
174 | "from": "CodeChunk",
|
175 | "isArray": true,
|
176 | "isPlural": true,
|
177 | "aliases": [
|
178 | "alter"
|
179 | ]
|
180 | },
|
181 | "uses": {
|
182 | "@id": "stencila:uses",
|
183 | "description": "Names of variables that the code chunk uses (but does not alter).",
|
184 | "type": "array",
|
185 | "items": {
|
186 | "anyOf": [
|
187 | {
|
188 | "type": "string"
|
189 | },
|
190 | {
|
191 | "$ref": "Variable.schema.json"
|
192 | }
|
193 | ]
|
194 | },
|
195 | "from": "CodeChunk",
|
196 | "isArray": true,
|
197 | "isPlural": true,
|
198 | "aliases": [
|
199 | "use"
|
200 | ]
|
201 | },
|
202 | "reads": {
|
203 | "@id": "stencila:reads",
|
204 | "description": "Filesystem paths that this code chunk reads from.",
|
205 | "type": "array",
|
206 | "items": {
|
207 | "type": "string"
|
208 | },
|
209 | "from": "CodeChunk",
|
210 | "isArray": true,
|
211 | "isPlural": true,
|
212 | "aliases": [
|
213 | "read"
|
214 | ]
|
215 | },
|
216 | "outputs": {
|
217 | "@id": "stencila:outputs",
|
218 | "description": "Outputs from executing the chunk.",
|
219 | "type": "array",
|
220 | "items": {
|
221 | "$ref": "Node.schema.json"
|
222 | },
|
223 | "from": "CodeChunk",
|
224 | "isArray": true,
|
225 | "isPlural": true,
|
226 | "aliases": [
|
227 | "output"
|
228 | ]
|
229 | },
|
230 | "errors": {
|
231 | "@id": "stencila:errors",
|
232 | "description": "Errors when compiling or executing the chunk.",
|
233 | "type": "array",
|
234 | "items": {
|
235 | "$ref": "CodeError.schema.json"
|
236 | },
|
237 | "from": "CodeChunk",
|
238 | "isArray": true,
|
239 | "isPlural": true,
|
240 | "aliases": [
|
241 | "error"
|
242 | ]
|
243 | },
|
244 | "duration": {
|
245 | "@id": "stencila:duration",
|
246 | "description": "Duration in seconds of the last execution of the chunk.",
|
247 | "type": "number",
|
248 | "minimum": 0,
|
249 | "from": "CodeChunk"
|
250 | }
|
251 | },
|
252 | "file": "CodeChunk.schema.yaml",
|
253 | "children": [],
|
254 | "descendants": [],
|
255 | "$schema": "http://json-schema.org/draft-07/schema#",
|
256 | "$id": "https://schema.stenci.la/v0/CodeChunk.schema.json",
|
257 | "source": "https://github.com/stencila/schema/blob/master/CodeChunk.schema.yaml",
|
258 | "type": "object",
|
259 | "propertyAliases": {
|
260 | "encoding": "format",
|
261 | "encodingFormat": "format",
|
262 | "export": "importTo",
|
263 | "import": "imports",
|
264 | "declare": "declares",
|
265 | "assign": "assigns",
|
266 | "alter": "alters",
|
267 | "use": "uses",
|
268 | "read": "reads",
|
269 | "output": "outputs",
|
270 | "error": "errors"
|
271 | },
|
272 | "additionalProperties": false,
|
273 | "required": [
|
274 | "type",
|
275 | "text"
|
276 | ]
|
277 | }
|