Skip to main content


A executable chunk of code.


Name@idTypeDescriptionInherited from
textschema:textstringThe text of the code.Code
typeschema:type'CodeChunk'The name of the type.Entity
altersstencila:altersArray of stringNames of variables that the code chunk alters. See note 2.CodeChunk
assignsstencila:assignsArray of (Variable or string)Variables that the code chunk assigns to. See note 1.CodeChunk
captionschema:captionArray of BlockContent or stringA caption for the CodeChunk. See note 3.CodeChunk
declaresstencila:declaresArray of (Variable or Function or string)Variables that the code chunk declares.CodeChunk
durationstencila:durationnumberDuration in seconds of the last execution of the chunk.CodeChunk
errorsstencila:errorsArray of CodeErrorErrors when compiling or executing the chunk.CodeChunk
exportFromstencila:exportFromstringA compilation directive giving the name of the variable to export into the content of the code block.CodeBlock
formatschema:encodingFormatstringMedia type, typically expressed using a MIME format, of the code. See note 4.Code
idschema:idstringThe identifier for this item.Entity
importTostencila:importTostringA compilation directive giving the name of the variable to import the content of the code block as.CodeBlock
importsstencila:importsArray of (SoftwareSourceCode or SoftwareApplication or string)Software packages that the code chunk importsCodeChunk
labelstencila:labelstringA short label for the CodeChunk.CodeChunk
metastencila:metaobjectMetadata associated with this item.Entity
outputsstencila:outputsArray of NodeOutputs from executing the chunk.CodeChunk
programmingLanguageschema:programmingLanguagestringThe programming language of the code.Code
readsstencila:readsArray of stringFilesystem paths that this code chunk reads from.CodeChunk
usesstencila:usesArray of (Variable or string)Names of variables that the code chunk uses (but does not alter).CodeChunk



  1. assigns : In languages such as Python and R we are unable to differentiate between an assignment that is a declaration and an assignment that is an alteration (a re-assignment). The "primary" compiler keeps a track of the variables declared in code chunks prior to the current chunk in the document and may treat an assignment as a declaration.
  2. alters : This property allows users to add undetected alterations (i.e. not assignments) to this list. Chunks that alter a variable need to be inserted into the dependency graph between declares and uses
  3. caption : An array of nodes or, to be compatible with, a string.
  4. format : 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.
  5. Available as JSON-LD.
  6. Available as JSON Schema.
  7. This documentation was generated from CodeChunk.schema.yaml.