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

[3/?] Add ability to run code examples in the playground: Fetch tutorial snippet from URL by file name #542

Draft
wants to merge 33 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
765384b
feat(config): Activate mkdocs snippets extension
shaedrich Apr 21, 2024
c1a8a22
refactor(code-samples): Turn code samples into snippets
shaedrich Apr 21, 2024
58e6599
fix(config): Add missing colon
shaedrich Apr 21, 2024
62a001d
feat(config): Enable check_paths option for snippets
shaedrich Apr 21, 2024
c6b9959
fix(code-samples): :pencil2: Fix snippet file embed path
shaedrich Apr 21, 2024
dc86c15
Merge branch 'code-samples-separate-files' of https://github.com/shae…
shaedrich Apr 21, 2024
70dad88
refactor(code-samples): :memo: Turn code samples into snippets for "O…
shaedrich Apr 21, 2024
2464d02
refactor(code-samples): :memo: Turn code samples into snippets for "P…
shaedrich Apr 21, 2024
50e60d2
refactor(code-samples): :memo: Turn code samples into snippets for "T…
shaedrich Apr 21, 2024
676f5ee
fix(code-samples): :pencil2: Fix snippet file embed path
shaedrich Apr 21, 2024
c0a6b17
refactor(code-samples): :memo: Turn code samples into snippets for "G…
shaedrich Apr 21, 2024
003722b
fix(code-samples): :pencil2: Shorten snippet line syntax
shaedrich Apr 21, 2024
fd48fe3
refactor(code-samples): :memo: Turn code samples into snippets for "T…
shaedrich Apr 21, 2024
f983690
fix(code-samples): :pencil2: Fix snippet file embed path
shaedrich Apr 21, 2024
27e0623
fix(code-samples): :pencil2: Fix snippet file name
shaedrich Apr 21, 2024
154c7dc
cont'd
shaedrich Apr 21, 2024
cc8c939
refactor(code-samples): :memo: Turn code samples into snippets for "E…
shaedrich Apr 21, 2024
999c6c4
fix(code-samples): :pencil2: Fix snippet file name
shaedrich Apr 21, 2024
706c0d0
refactor(code-samples): :memo: Turn code samples into snippets for "R…
shaedrich Apr 22, 2024
cc1f53a
refactor(code-samples): :memo: Turn code samples into snippets for "G…
shaedrich Apr 22, 2024
bb74be7
fix(code-samples): :pencil2: Fix snippet file embed path
shaedrich Apr 22, 2024
2e6bc8a
fix(code-samples): :pencil2: Shorten snippet line syntax
shaedrich Apr 22, 2024
57bbbeb
refactor(code-samples): :memo: Turn code samples into snippets for "C…
shaedrich Apr 22, 2024
5b35814
refactor(code-samples): :memo: Turn code samples into snippets for "A…
shaedrich Apr 22, 2024
420d05a
fix(code-samples): :pencil2: Fix snippet file name
shaedrich Apr 22, 2024
1a22c1a
fix(code-samples): :pencil2: Fix snippet file embed path
shaedrich Apr 22, 2024
9046f63
feat(config): :wrench: Activate mkdocs attr_list and pymdownx.emoji e…
shaedrich Apr 22, 2024
b38ee20
feat(code-samples): :sparkles: Add "Run in playground" button to "hel…
shaedrich Apr 22, 2024
e5680a7
fix(docs): ✏️ Fix spacing
shaedrich Apr 30, 2024
5787880
Merge branch 'main' into code-samples-footer-run-button
shaedrich May 21, 2024
3339fd2
refactor(code-samples): 📝 Revert non-pony code samples
shaedrich May 21, 2024
955e189
Add "fontawesome" to spelling-wordlist
shaedrich May 21, 2024
469dabf
Revert non-pony error message code samples
shaedrich May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .spelling-wordlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ FFI
filesystem
finaliser
finalisers
fontawesome
forgeable
GC
GDB
Expand Down
8 changes: 7 additions & 1 deletion docs/generics/generics-and-reference-capabilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,13 @@ That compiles and runs, so `ref` is valid now. The real test though is `iso`. Le
This fails to compile. The first error is:

```error
--8<-- "generics-and-reference-capabilities-foo-iso-error-message.txt"
main.pony:5:8: right side must be a subtype of left side
_c = c
^
Info:
main.pony:4:17: String iso! is not a subtype of String iso: iso! is not a subtype of iso
new create(c: String iso) =>
^
Comment on lines +53 to +59
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks unrelated to the change?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kinda. This was because the PR was created alongside previous PRs and when we reverted non-pony examples and cherry-picked them, not everything looked exactly pretty in the commit history 😅

```

The error is telling us that we are aliasing the `String iso` - The `!` in `iso!` means it is an alias of an existing `iso`. Looking at the code shows the problem:
Expand Down
2 changes: 2 additions & 0 deletions docs/getting-started/hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ In your file, put the following code:
--8<-- "hello-world-main.pony"
```

[:fontawesome-solid-play: Run in playground](https://playground.ponylang.io/?snippet=hello-world-main.pony){ .md-button .md-button--primary target="_blank" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way we could automatically render this button for every .pony snippet instead of needing to paste this button code ourselves all over the markdown, and maintain that?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and no. Not with the current setup. But that's why I'm experimenting with #555.


## Compiling the program

Now compile it:
Expand Down
4 changes: 4 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ markdown_extensions:
- pymdownx.snippets:
base_path: ['code-samples']
check_paths: true
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
- attr_list
- smarty
- toc:
permalink: true
Expand Down