Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Execution: Add stderr block #2397

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Execution: Add stderr block #2397

wants to merge 1 commit into from

Conversation

Alx-Lai
Copy link
Contributor

@Alx-Lai Alx-Lai commented Oct 6, 2024

Add a stderr block.
Pros:

  • we can make use of dbg macro in our code Cons:
  • there's a limitation that the compile message also shows

Applies patches from rust-lang/mdBook#1315 since the original change was not merged by rust-lang.

Issue: #531

@mgeisler
Copy link
Collaborator

mgeisler commented Oct 6, 2024

Hi @Alx-Lai, oh wow, this patch looks great! Thanks a lot for looking into this, I would very much like to have this feature implemented.

I gave the PR a quick test run locally and this is how it looks:

Screencast.from.2024-10-06.23-12-20.mp4

This is nearly perfect. A few comments:

  • Could you match and remove the three lines that appear when things compile correctly? The lines which say:

       Compiling playground v0.0.1 (/playground)
        Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.60s
         Running `target/debug/playground`
    

    By removing them in the happy case, we end up with the same output as today, which helps limit the amount of vertical space used. This is important for a live class where it's very disturbing to scroll up and down :)

  • Could you avoid showing the stderr block immediately when compilation starts? Ideally, there would be a single output with the combination of stdout and stderr, but I understand that the Playground delivers the data in two separate fields.

  • Similarly, the block with the stderr output should be hidden/cleared when the code is recompiled.

I looked briefly at the full Playground and discovered that they use a WebSocket now to stream the output line by line! They include markers to show if this is a stdout or stderr:

image

I would be happy to merge this PR as a first step — I don't know how difficult it will be to adapt the mdbook code to use a WebSocket as well.

@Alx-Lai
Copy link
Contributor Author

Alx-Lai commented Oct 6, 2024

Ok, I'll spend time looking into it. Thanks for the feedback!

Add a stderr block.
Pros:
  - we can make use of dbg macro in our code
Cons:
  - there's a limitation that the compile message also shows

To be improved:
  - compile message regex may change overtime
  - can use websocket to replace the current approach

Applies patches from rust-lang/mdBook#1315 since the original change
was not merged by rust-lang.

Signed-off-by: Alx-Lai <[email protected]>
@Alx-Lai
Copy link
Contributor Author

Alx-Lai commented Oct 7, 2024

Updated the commit.

  • Remove compile message with a not-that-elegant way, the compile error message would not be replaced.
  • hide and clear stderr block before compiling the code.

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.

2 participants