feedback icon indicating copy to clipboard operation
feedback copied to clipboard

Compiled code drops leading/following comments

Open mootari opened this issue 4 years ago • 1 comments

Describe the bug

If a cell contains comments before the first statement or after the last, then these comments are not included in the exported module. This poses a problem, as it means that inlined attribution might get dropped. This behavior is not intuitive and may cause authors to involuntarily violate licenses of copied code.

Expected behavior

Given a cell:

// Comment before
foo = "bar"
// Comment after

the compiled code should read:

  main.variable(observer("foo")).define("foo", function(){return(
// Comment before
"bar"
// Comment after
)});

mootari avatar Feb 08 '22 16:02 mootari

It also becomes impossible to properly use JSDoc style inline documentation, as leading docblocks are dropped. In order to access them, one would have to fetch the raw cell contents from Observable's internal API.

mootari avatar Feb 08 '22 17:02 mootari