From d557097545793ee1c0501bd092b02ee34a3ce165 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Vogel?= <104342347+cedricvogel-leo@users.noreply.github.com> Date: Thu, 5 Nov 2026 16:53:59 +0100 Subject: [PATCH] features=listtree: lists as trees (P34 B) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "listtree" passes on to the embed, which draws a list whose first element is a string also as a tree (variables, full value, console). Like "coverage" it isn't part of «everything». examples/profiles.md gets a "baum" profile. Co-Authored-By: Claude Opus 5.5 --- README.md | 15 ++++++++++++--- examples/profiles.md | 19 ++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f071a60..626e099 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,13 @@ window.__glpythonMount = (args, send) => { const libraryUrls = options.filter((option) => /^https?:\/\//.test(option)) // "features=run,repl,…" shows only these parts (the course builds its // profiles from it); without it, everything shows - except "coverage" - // (after Tests, the lines no example executed), which a course switches on + // (after Tests, the lines no example executed) and "listtree" (lists such + // as ["+", 2, 3] also drawn as a tree), which a course switches on // explicitly. "large" enlarges the code and the visualizer, e.g. for a demo // on the projector. - const featureNames = ["run", "tests", "visualize", "reset", "repl", "export", "ide", "coverage"] + const featureNames = ["run", "tests", "visualize", "reset", "repl", "export", "ide", "coverage", "listtree"] const featuresOption = options.find((option) => option.startsWith("features=")) - const requestedFeatures = featuresOption ? featuresOption.slice("features=".length).split(",").map((name) => name.trim()).filter(Boolean) : featureNames.filter((name) => name !== "coverage") + const requestedFeatures = featuresOption ? featuresOption.slice("features=".length).split(",").map((name) => name.trim()).filter(Boolean) : featureNames.filter((name) => name !== "coverage" && name !== "listtree") const unknownFeatures = requestedFeatures.filter((name) => !featureNames.includes(name)) const hasFeature = (name) => requestedFeatures.includes(name) const large = options.includes("large") @@ -1068,6 +1069,14 @@ examples check the edge cases. Coverage finds untested code, not wrong code: counts, not libraries or other files, and only lines in function bodies (not `def` lines, docstrings or code outside functions). Nothing is marked in the block's code editor; the report gives the line and its code. + +`listtree` isn't part of «everything» either. It draws a list whose first +element is a string, such as `["+", 2, ["*", 3, 4]]`, also as a tree: in the +visualizer's variables (a wide tree behind «Baum zeigen»), in the full value's +window, and in the console, where such a value gets a «Baum» button next to +«Visualisieren». The visualizer's ⋮ menu can switch the trees off («Listen als +Baum zeigen»). Each tree is described by the list's own text for screen +readers. `large` makes the code 20px (line height 1.6) and the visualizer at least 60% of the window, e.g. for the projector in presentation mode. diff --git a/examples/profiles.md b/examples/profiles.md index 71bb0bd..d334dbe 100644 --- a/examples/profiles.md +++ b/examples/profiles.md @@ -18,6 +18,8 @@ import: https://raw.githubusercontent.com/glpython-edu/glpython-liascript/main @Code.voll: @GLPython.eval(@0) +@Code.baum: @GLPython.eval(features=run,repl,visualize,ide,listtree @0) + @Code.demo: @GLPython.visual(large @0) --> @@ -33,6 +35,7 @@ Jede Folie zeigt ein Profil des Kurses. Die Profile sind Makros des Kurses, die | rezept3 | `features=run,repl,visualize,tests,ide,coverage` | | pruefung | `features=run` | | voll | (alles) | +| baum | `features=run,repl,visualize,ide,listtree` | | demo | `@GLPython.visual(large)` | ## erkunden @@ -185,7 +188,7 @@ print(quadrat(7)) ## voll -Ohne `features=`: alles wie bisher. +Ohne `features=`: alles wie bisher, ohne Abdeckung und ohne Bäume. ```python def quadrat(x): @@ -199,6 +202,20 @@ print(quadrat(7)) ``` @Code.voll +## baum + +Listen wie `["+", 2, 3]` auch als Baum: in den Variablen des Visualisierers, im +Fenster des ganzen Werts und in der Konsole (Knopf «Baum», z. B. nach +`ausdruck` in der Eingabezeile). + +```python +ausdruck = ["+", 2, ["*", 3, 4]] +zahlen = [1, 2, 3] +breit = ["f", ["g", "erstes", "zweites"], ["h", "drittes", "viertes"], ["k", "fünftes"]] +print(ausdruck) +``` +@Code.baum + ## demo Nur der Visualisierer, gross - für den Projektor.