ponylang / pony-tutorial

:horse: Tutorial for the Pony programming language
http://tutorial.ponylang.io
BSD 2-Clause "Simplified" License
308 stars 111 forks source link

[2/?] Add ability to run code examples in the playground: Extend code samples to be runnable #545

Closed shaedrich closed 4 months ago

shaedrich commented 5 months ago

See #340

As per https://github.com/ponylang/pony-tutorial/pull/542#issuecomment-2113695598

Stats

Files

Getting Started

Types

traits-and-interfaces-structural-subtyping.pony:18:19 --8<-- → runnable

Expressions

Reference capabilities

Object capabilities

Generics

Packages

Testing

C-FFI

Gotchas

Appendices

netlify[bot] commented 5 months ago

Deploy Preview for pony-tutorial ready!

Name Link
Latest commit f3c555243bcf24ea093142427588539226d95b47
Latest deploy log https://app.netlify.com/sites/pony-tutorial/deploys/665f5b08f477050008365761
Deploy Preview https://deploy-preview-545--pony-tutorial.netlify.app
Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

shaedrich commented 5 months ago

fyi: There's currently an issue with auto dedention (https://github.com/facelessuser/pymdown-extensions/issues/1945) when using the block format and splitting a snippet into multiple pieces: https://github.com/facelessuser/pymdown-extensions/issues/2385

shaedrich commented 5 months ago

Main problems with files tagged "not runnable", that could potentially be runnable

shaedrich commented 5 months ago

When examples are taken from stdlib, wouldn't it make sense to use URL snippets (or, assuming, all the sites are on the same server, maybe another path in mkdocs.yml markdown_extensions.pymdownx.snippets.base_path would suffice) from https://github.com/ponylang/ponyc (example)?

shaedrich commented 5 months ago

Guide on how to read the PR description and what we might want to do with it

shaedrich commented 5 months ago

fyi: The deploy preview only fails due to flaky connectivity.

SeanTAllen commented 4 months ago

Error from the last build log:

12:41:17 PM: ERROR - Error reading page 'c-ffi/calling-c.md': Snippet at path 'https://raw.githubusercontent.com/ponylang/ponyc/main/packages/builtin/float.pony' could not be found

SeanTAllen commented 4 months ago

This is an impressive amount of work. Thank you @shaedrich.

shaedrich commented 4 months ago

This is an impressive amount of work. Thank you @shaedrich.

@SeanTAllen Thanks a lot 😊

Error from the last build log:

12:41:17 PM: ERROR - Error reading page 'c-ffi/calling-c.md': Snippet at path 'https://raw.githubusercontent.com/ponylang/ponyc/main/packages/builtin/float.pony' could not be found

@SeanTAllen This is fixed by the revert requested by @jemc

jemc commented 4 months ago

Is this PR meant to be in a ready for review/merge state?

I ask because it's not marked as a draft, but there are unchecked checkboxes in the PR description.

It isn't clear to me whether we should be giving this a final review yet.

shaedrich commented 4 months ago

@jemc Please read the PR description as well as my previous comments. If none of them require any action in your opinion, the PR is indeed ready to be merged. The unchecked checkboxes mean, these code snippets are not runnable and might not have been changed in this PR, but this doesn't necessarily need to be a problem.

shaedrich commented 4 months ago

Well, what use is it to have an example being run by the playground and it just doesn't fail? When I use the playground, I want it to output something. Otherwise the tutorial can simply talk about code and I have to accept that it does what the text says.

jemc commented 4 months ago

I think what you've done here does add value to the kind of user who wants to click through on these code samples and run them in the playground. I don't think that will be a high volume of users, but I agree your work here adds value for them (which is why I marked it as approved).

However, I don't want to create new requirements for tutorial content that raise the bar for what needs to be created there. That's why I want to ensure that the future mechanism which tests these samples can run at least some samples in a mode where we're only verifying that they compile (which should be part of the minimum bar for tutorial content contribution - that the code samples compile if expected to compile, or fail with specified errors if they are expected to fail to compile).

In short, we have to balance the needs of both the tutorial reader and the tutorial contributor. The more friction we add to the tutorial contribution process, the harder it becomes to get volunteers to do the work.

shaedrich commented 4 months ago

fail with specified errors

This one is a bit puzzling to me. So, in essence, you want failure to be more defined than success? That doesn't make sense to me. You don't want to test beyond compilation, okay, but why bother with error codes/messages? Why not just make a *.txt file with one exception per line that isn't tested and be done with it? Low maintenance, exactly what you want.

jemc commented 4 months ago

I'm trying to engage in a good faith exchange of opinions and arguments/reasoning here, but it becomes hard to justify continuing that engagement when comments like this appear to be strawmanning me with an apparent petulant tone.

Why not just make a *.txt file with one exception per line that isn't tested and be done with it? Low maintenance, exactly what you want.

We've talked at length in this PR and elsewhere about "what I want" and that isn't it.

So, no.

shaedrich commented 4 months ago

I'm trying to engage in a good faith exchange of opinions and arguments/reasoning here, but it becomes hard to justify continuing that engagement when comments like this appear to be strawmanning me with an apparent petulant tone.

It's right when they say, the internet doesn't do a good point of getting one's point across in terms of the message's notions. If you indeed read my message in good faith, there is nothing that would objectively hint at a petulant tone.

What I'm trying to do is merely to understand your position, which I'm struggling to do, as I tried to convey in my last message. If you're willing to make this clear, I'm interested in your explanation. If you don't want to and still take this personally, there's not much I can do.

In more than one comment, I explicitly stated that I hope, I'm not speaking out of line by just stating my different opinion on the matter at hand because I thought, this perspective would be beneficial for the project.

I just listened to your sync recording, and I think, I understand one of your concerns better, concerning using stderr to determine if the code snippet run failed accordingly. Yeah, error messages could change, so something else should be used. Meaning, the problem is not with wanting to determine the reason of the run failing but the way of achieving that. However, this is complicated in itself, but might become easier if ponylang/rfcs#76 got implemented.