Skip to main content

Code Chunk

A executable chunk of code.

This schema type is marked as unstable ⚠️ and is subject to change.


Name@idTypeDescriptionInherited from
programmingLanguageschema:programmingLanguagestringThe programming language of the code.Code
textschema:textstringThe text of the code.Code
captionschema:captionArray of BlockContent or stringA caption for the CodeChunk. See note 1.CodeChunk
codeDependenciesstencila:codeDependenciesArray of (CodeChunk or Parameter)The upstream dependencies of the code. See note 2.CodeExecutable
codeDependentsstencila:codeDependentsArray of (CodeChunk or CodeExpression)The downstream dependents of the code. See note 3.CodeExecutable
compileDigeststencila:compileDigeststringA digest of the content, semantics and dependencies of the node.CodeExecutable
errorsstencila:errorsArray of CodeErrorErrors when compiling (e.g. syntax errors) or executing the chunk.CodeExecutable
executeAutostencila:executeAuto'Never', 'Needed', 'Always'Under which circumstances the node should be automatically executed. See note 4.CodeChunk
executeCountstencila:executeCountintegerA count of the number of times that the node has been executed. See note 5.CodeExecutable
executeDigeststencila:executeDigeststringThe compileDigest of the node when it was last executed.CodeExecutable
executeDurationstencila:executeDurationnumberDuration in seconds of the last execution of the code.CodeExecutable
executeEndedstencila:executeEndedDateThe date-time that the the last execution of the code ended.CodeExecutable
executePurestencila:executePurebooleanWhether the code should be treated as side-effect free when executed.CodeChunk
executeRequiredstencila:executeRequired'No', 'NeverExecuted', 'SemanticsChanged', 'DependenciesChanged', 'DependenciesFailed'Whether, and why, a node requires execution or re-execution. See note 6.CodeExecutable
executeStatusstencila:executeStatus'Scheduled', 'ScheduledPreviouslyFailed', 'Running', 'RunningPreviouslyFailed', 'Succeeded', 'Failed', 'Cancelled'Status of the most recent, including any current, execution of the code.CodeExecutable
idschema:idstringThe identifier for this item.Entity
labelstencila:labelstringA short label for the CodeChunk.CodeChunk
mediaTypeschema:encodingFormatstringMedia type, typically expressed using a MIME format, of the code. See note 7.Code
metastencila:metaobjectMetadata associated with this item.Entity
outputsstencila:outputsArray of NodeOutputs from executing the chunk.CodeChunk


  1. caption : An array of nodes or, to be compatible with, a string.
  2. codeDependencies : Note that this excludes CodeExpression nodes since they should not have side effects (e.g. assigning variables) that would cause another node to be dependent upon them.
  3. codeDependents : Note that in comparison to codeDependencies, this property does not allow for Parameter dependents (because parameters are never dependent upon others).
  4. executeAuto : Never: Never automatically execute the code chunk. Only execute when the user explicitly runs the code (or its containing document). Needed: Automatically execute the code chunk if needed. Execute the code chunk if it is an upstream dependency of a node that has been executed, or is a downstream dependent of a node that has been executed. Always: Always execute the code, even if it, or its dependencies, are unchanged since the last time it was executed.
  5. executeCount : Intended to increment with each successive execution of the node, including across sessions. Note that this differs to the execution_count in Jupyter Notebook format which is the "code cell's prompt number" and which resets at the start of each new session.
  6. executeRequired : Derived from a comparison of compileDigest and executeDigest and the executeStatus of dependencies. No: no re-execution is required, the semantics of the code and its dependencies has not changed since it was last executed. NeverExecuted: execution is required because the code has never been executed (or any previous execution was not persisted in its state). SemanticsChanged: re-execution is required because the semantics of the code has changed since it was last executed. DependenciesChanged: the semantics of one or more dependencies (including transitive dependencies) changed since it was last executed. DependenciesFailed: one or more dependencies (including transitive dependencies) failed when it was last executed.
  7. mediaType : This property allows the differentiation of formats using the same programming language or variants of a programming language. An example is using programmingLanguage "json" and encodingFormat "application/ld+json" for JSON-LD code examples.


"type": "CodeChunk",
"programmingLanguage": "python",
"text": "print('Hello world!')"

Available as


This documentation was generated from CodeChunk.schema.yaml.