A executable chunk of code.


Name @id Type Description Inherited from
text schema:text string The text of the code. Code
alters stencila:alters Array of string Names of variables that the code chunk alters. See note 2. CodeChunk
assigns stencila:assigns Array of (Variable or string) Variables that the code chunk assigns to. See note 1. CodeChunk
caption schema:caption Array of BlockContent or string A caption for the CodeChunk. See note 3. CodeChunk
declares stencila:declares Array of (Variable or Function or string) Variables that the code chunk declares. CodeChunk
duration stencila:duration number Duration in seconds of the last execution of the chunk. CodeChunk
errors stencila:errors Array of CodeError Errors when compiling or executing the chunk. CodeChunk
exportFrom stencila:exportFrom string A compilation directive giving the name of the variable to export into the content of the code block. CodeBlock
format schema:encodingFormat string Media type, typically expressed using a MIME format, of the code. See note 4. Code
id schema:id string The identifier for this item. Entity
importTo stencila:importTo string A compilation directive giving the name of the variable to import the content of the code block as. CodeBlock
imports stencila:imports Array of (SoftwareSourceCode or SoftwareApplication or string) Software packages that the code chunk imports CodeChunk
label stencila:label string A short label for the CodeChunk. CodeChunk
meta stencila:meta object Metadata associated with this item. Entity
outputs stencila:outputs Array of Node Outputs from executing the chunk. CodeChunk
programmingLanguage schema:programmingLanguage string The programming language of the code. Code
reads stencila:reads Array of string Filesystem paths that this code chunk reads from. CodeChunk
uses stencila:uses Array 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.

Available as


This documentation was generated from CodeChunk.schema.yaml.