asg017 / dataflow

An experimental self-hosted Observable notebook editor, with support for FileAttachments, Secrets, custom standard libraries, and more!
https://alexgarcia.xyz/dataflow/
MIT License
400 stars 24 forks source link

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

Open asg017 opened 3 years ago

asg017 commented 3 years ago

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.