Repository: ibis-project/ibis

Issue:
docs: https://ibis-project.org/reference/expression-generic#examples-36
### Please describe the issue

There is an error:
```
IbisError: Expression contains unbound tables and therefore cannot be executed. Use ibis.<backend>.execute(expr) or assign a backend instance to `ibis.options.default_backend`.
```
I reproduce this. What about this one?

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct


Discussion:
Thanks for the report, definitely a bug!

Resolving patch:
diff --git a/docs/_renderer.py b/docs/_renderer.py
--- a/docs/_renderer.py
+++ b/docs/_renderer.py
@@ -1,5 +1,7 @@
 from __future__ import annotations
 
+from textwrap import dedent
+
 import quartodoc as qd
 import toolz
 from plum import dispatch
@@ -26,6 +28,8 @@ def render(self, el: qd.ast.ExampleCode) -> str:
             lambda line: quartodoc_skip_doctest in line or skip_doctest in line
         )
 
+        has_executed_chunks = False
+
         for chunk in toolz.partitionby(chunker, lines):
             first, *rest = chunk
 
@@ -35,10 +39,11 @@ def render(self, el: qd.ast.ExampleCode) -> str:
                 # check whether to skip execution and if so, render the code
                 # block as `python` (not `{python}`) if it's marked with
                 # skip_doctest, expect_failure or quartodoc_skip_doctest
-                if not any(map(should_skip, chunk)):
-                    start, end = "{}"
-                else:
+                if any(map(should_skip, chunk)):
                     start = end = ""
+                else:
+                    has_executed_chunks = True
+                    start, end = "{}"
 
                 result.append(f"```{start}python{end}")
 
@@ -62,4 +67,22 @@ def render(self, el: qd.ast.ExampleCode) -> str:
                 result.extend(rest)
                 result.append("```\n")
 
-        return "\n".join(result)
+        examples = "\n".join(result)
+
+        if has_executed_chunks:
+            # turn off interactive mode before rendering
+            return (
+                dedent(
+                    """
+                    ```{python}
+                    #| echo: false
+
+                    import ibis
+                    ibis.options.interactive = False
+                    ```
+                    """
+                )
+                + examples
+            )
+        else:
+            return examples
diff --git a/ibis/expr/api.py b/ibis/expr/api.py
--- a/ibis/expr/api.py
+++ b/ibis/expr/api.py
@@ -244,21 +244,22 @@ def param(type: dt.DataType) -> ir.Scalar:
 
     Examples
     --------
+    >>> from datetime import date
     >>> import ibis
     >>> start = ibis.param("date")
-    >>> end = ibis.param("date")
-    >>> schema = dict(timestamp_col="timestamp", value="double")
-    >>> t = ibis.table(schema, name="t")
-    >>> predicates = [t.timestamp_col >= start, t.timestamp_col <= end]
-    >>> t.filter(predicates).value.sum()
-    r0 := UnboundTable: t
-      timestamp_col timestamp
-      value         float64
-    r1 := Selection[r0]
-      predicates:
-        r0.timestamp_col >= $(date)
-        r0.timestamp_col <= $(date)
-    Sum(value): Sum(r1.value)
+    >>> t = ibis.memtable(
+    ...     {
+    ...         "date_col": [date(2013, 1, 1), date(2013, 1, 2), date(2013, 1, 3)],
+    ...         "value": [1.0, 2.0, 3.0],
+    ...     },
+    ... )
+    >>> expr = t.filter(t.date_col >= start).value.sum()
+    >>> expr.execute(params={start: date(2013, 1, 1)})
+    6.0
+    >>> expr.execute(params={start: date(2013, 1, 2)})
+    5.0
+    >>> expr.execute(params={start: date(2013, 1, 3)})
+    3.0
     """
     return ops.ScalarParameter(type).to_expr()
 
diff --git a/ibis/expr/types/generic.py b/ibis/expr/types/generic.py
--- a/ibis/expr/types/generic.py
+++ b/ibis/expr/types/generic.py
@@ -42,11 +42,26 @@ def name(self, name):
         Examples
         --------
         >>> import ibis
-        >>> t = ibis.table(dict(a="int64"), name="t")
+        >>> ibis.options.interactive = True
+        >>> t = ibis.memtable({"a": [1, 2]}, name="t")
+        >>> t.a
+        ┏━━━━━━━┓
+        ┃ a     ┃
+        ┡━━━━━━━┩
+        │ int64 │
+        ├───────┤
+        │     1 │
+        │     2 │
+        └───────┘
         >>> t.a.name("b")
-        r0 := UnboundTable: t
-          a int64
-        b: r0.a
+        ┏━━━━━━━┓
+        ┃ b     ┃
+        ┡━━━━━━━┩
+        │ int64 │
+        ├───────┤
+        │     1 │
+        │     2 │
+        └───────┘
         """
         # TODO(kszucs): shouldn't do simplification here, but rather later
         # when simplifying the whole operation tree


Test patch: