jupyter-book icon indicating copy to clipboard operation
jupyter-book copied to clipboard

Better inline eval tutorial.

Open yuxi-liu-wired opened this issue 2 years ago • 2 comments

Context

First, I think it's necessary to put this somewhere prominent in the tutorial. Tell the reader that if they want to inline a reference, they need to put this in the yaml. It took me an hour of searching just to notice that this is what we need.

mystnb:
    execution_mode: 'inline'

Considering that I switched to Jupyter Book specifically because I couldn't deal with the lack of inline reference in Jupyter Lab, and found Jupyter Book because of this pointer in https://discourse.jupyter.org/t/inline-variable-insertion-in-markdown/10525 , this feature really should be shown in the tutorial, perhaps putting this segment specifically into the "getting started" default project.

Next let's try some inline text reference.

```{code-cell}
def fibb(n):
    a, b = 0, 1
    for i in range(n):
        a, b = b, a + b
    return a
print(fibb(10))
fibb10 = fibb(10)
```

The 10th Fibonacci number is {eval}`fibb10`.

I also feel like it would be good if I can use inline evals, like instead of defining a temporary variable just to insert it into text, I would like it to be evaluated right at the point.

For example, it'd be cool if I can do this instead:

The 10th Fibonacci number is {eval}`fibb(10)`.

Proposal

No response

Tasks and updates

No response

yuxi-liu-wired avatar Sep 27 '23 23:09 yuxi-liu-wired

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.
If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).
Welcome to the EBP community! :tada:

welcome[bot] avatar Sep 27 '23 23:09 welcome[bot]

Hi @yuxiliu1995, thanks for the feedback! Yes, we could make that aspect more obvious. We probably should error if we encounter evals in a non-Eval context.

We have added support for more general expressions, hidden behind a config flag. It will be released in the next version of myst-nb, which is coming soon.

agoose77 avatar Sep 27 '23 23:09 agoose77