Skip to content

Wrap naked expressions in playground blocks with console.log()#251

Merged
mrjf merged 2 commits intomainfrom
copilot/add-console-log-to-playground
Apr 30, 2026
Merged

Wrap naked expressions in playground blocks with console.log()#251
mrjf merged 2 commits intomainfrom
copilot/add-console-log-to-playground

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Most playground tutorial blocks ended in bare expression statements (e.g. seriesAdd(a, b).values; // [5, 7, 9]) or const result = …; with the value documented only in a trailing comment. Since the playground runtime captures output exclusively from console.log/warn/error, clicking ▶ Run displayed (no output — add console.log() to see results) instead of demonstrating behavior. Audit found 425 of 770 blocks affected.

Changes

  • Wrap single-line expression statements in console.log(...), preserving indentation and inline // expected comments.
  • Append console.log(<lastVar>); to blocks whose only meaningful output is bound to a top-level const/let/var.
  • Skip non-runnable content: Python comparison snippets (import pandas, pd./np., print(, # end-of-line comments), TS type/signature reference lines (e.g. df.assign(spec: AssignSpec): DataFrame;), method-chain continuation lines (.toHtml();), multi-line statements (tracked via paren/brace/bracket depth), assignments (with HTML-entity decoding so =&gt; is recognized as =>), and placeholder blocks.

321 blocks across 70 playground/*.html files updated. Each block's TypeScript was transpiled before and after to confirm no new syntax errors.

Example

 import { Series, seriesAdd, seriesMul } from "tsb";

 const s = new Series({ data: [1, null, NaN, 4] });
-seriesAdd(s, 10).values;  // [11, null, NaN, 14]
-seriesMul(s, 2).values;   // [2, null, NaN, 8]
+console.log(seriesAdd(s, 10).values);  // [11, null, NaN, 14]
+console.log(seriesMul(s, 2).values);   // [2, null, NaN, 8]
 const df2 = dataFrameAssign(df, {
   c: [7, 8, 9],
   d: new Series({ data: [4, 5, 6] }),
 });
 // df2.columns.values  →  ["a", "b", "c", "d"]
+console.log(df2);

Not addressed

A handful of blocks remain output-less by design or due to pre-existing bugs unrelated to logging — pure interface/type declarations, comment-only snippets, and broken placeholders like Click ▶ Run to execute in crosstab.html/datetime_tz.html/factorize.html/get_dummies.html/str_get_dummies.html. Those warrant separate fixes.

Copilot AI linked an issue Apr 30, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add console.log() to demonstrate behavior in playground Wrap naked expressions in playground blocks with console.log() Apr 30, 2026
Copilot finished work on behalf of mrjf April 30, 2026 06:31
Copilot AI requested a review from mrjf April 30, 2026 06:31
@mrjf mrjf marked this pull request as ready for review April 30, 2026 15:30
@mrjf mrjf merged commit e78ce00 into main Apr 30, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(no output — add console.log() to see results)

2 participants