Skip to content

Allow code execution to generate rich outputs that are incorporated into the AST #1026

@choldgraf

Description

@choldgraf

Background

Code-cells can produce rich output like Markdown, LaTeX, and tables. Right now, these outputs are only rendered at display time, meaning that each static export and web build needs to interpret the MIME bundle outputs. As a result, the output content cannot participate in a MyST build, i.e. the Markdown or LaTeX output cannot generate or consume referencing labels.

We should parse this output along with the rest of the Markdown in the document. This would allow for programmatic generation of content, and along with the {embed} directive could allow users to nicely stitch together MyST content via any Jupyter Kernel.

Personas & Stories

Personas and stories for computation in MyST

An arbitrary persona wants to publish an online textbook

  • These notebooks may be executable.
  • They want to have reliable reproducible builds in CI.
  • They may want to pre-execute in a particular compute environment.

An instructor publishes their courseware

  • Their courseware is predominantly in notebooks with some markdown content.
  • They have worksheets that are executable, and students are expected to fill in the blanks with their solutions.
  • Instructors have reference solutions and want to be able to validate them e.g. in CI
  • Reference solutions should/may be visible to students to copy-paste and/or otherwise pull in.
  • Instructors may prefer students to remain inside the MyST site to do this.

A community maintainer creates a dashboard with MyST

  • Usage statistics of their GitHub Repo are compiled by a notebook.
  • The code-cells are run at build time to analyse data and generate content:
    • Tables; Pandas, Markdown
    • Arbitrary content
    • Figures: interactive plots and widgets
  • The resulting document is pushed to the web as an HTML build.

An Executive Director creates a monthly report

  • Financial data for the last month is scraped using an executable MyST document.
  • Some Markdown content outside of the code cells includes {eval} roles which utilise the data computed in other code-cells.
  • The code-cells are run at build time to analyse data and generate content:
    • Figures (plots)
    • Tables; Pandas, Markdown
    • Equations (TeX-math, Typst?)
    • Arbitrary content
  • The resulting document is published to a PDF via Typst.

A scientist publishes a reproducible paper

  • They have some (maybe hidden) notebooks generating interesting outputs like figures and tables.
  • The notebooks are run at build time to ensure a reproducible build
  • They either write their main manuscript in Markdown or TeX embedding:
    • Notebook outputs as figures to tables.
    • Code cells and programs.
  • OR, they write the paper in a top-to-bottom notebook(s).

A scientist publishes a computational article

  • The authors have included a mix of static and interactive figures, all of which are generated by notebooks.
  • The notebooks are run at build time to ensure a reproducible build.
  • The code-cells analyse data and generate interesting figures (plots, tables) that will be interactive.
  • They include interactive figures for data exploration, visualisation etc.
    • Some outputs are useable as static representations of the interactive cells (static plots)
    • Other outputs require manual placeholders (widgets)
  • They either write their main manuscript in Markdown:
    • Notebook outputs as figures to tables.
    • Code cells and programs.
  • OR, they write the paper in a top-to-bottom notebook(s)

Definition of done

  • It is possible to generate Markdown in a code-cell, and see it in a PDF build
  • The generated Markdown can define and consume reference targets that are visible to the rest of the project

Related issues

Sub-issues

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestinitiativeA collection of "stories" (enhancements, bug fixes, etc) that drive to a larger body of work

Projects

Status

In Progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions