asg017 / dataflow

An experimental self-hosted Observable notebook editor, with support for FileAttachments, Secrets, custom standard libraries, and more!

Home Page:https://alexgarcia.xyz/dataflow/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add option for displaying (non-editable) source code below rendered output

asg017 opened this issue · comments

dataflow run just executes the notebook, it doesn't display the source code like observablehq does.

A new option, --display-source, can be added to signal to dataflow that source code should be showed alongside the rendered output, so people can learn more/inspect the code if they want to learn more.

For example, this is example.ojs

// example.ojs

// @dataflow show
chart = {
  const canvas = DOM.canvas(width, 640);
  const ctx = canvas.getContext("2d");
  ctx.rect(0, 0, 100, 100);
  return canvas;
}

dataflow run example.ojs --display-source would then have show this in its rendered output:

+----------------------+
|    the canvas element  |
+----------------------+
+----------------------+
|       the source code     |
+----------------------+

instead of:

+----------------------+
|    the canvas element  |
+----------------------+
+----------------------+
|       the source code     |
+----------------------+

Something like a // @dataflow show could be used to "pin" cells to enable this on a cell-by-cell basis.

This would not be available in dataflow compile.