Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 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
45180f5
.gitignore: + /.vscode
shaedrich Apr 22, 2024
73e2d7e
feat(snippets): 🔧 Add snippet inline run JS
shaedrich Apr 30, 2024
d6fa1f8
feat(snippets): ✨ Add button to run snippet inline
shaedrich Apr 30, 2024
8594ce3
feat(config): 🔧 Activate mkdocs attr_list and pymdownx.emoji extensions
shaedrich Apr 30, 2024
1114b7e
fix(snippets): ✏️ Send POST request to evaluate.json API endpoint
shaedrich Apr 30, 2024
06cc3cf
fix(config): ✏️ Remove redundant implicit prefix
shaedrich Apr 30, 2024
d8565ca
chore(spelling): Add "fontawesome" to wordlist
shaedrich May 14, 2024
82929f6
Update .markdown-lint.yml
shaedrich May 15, 2024
1b074ef
Merge branch 'main' into code-samples-run-inline
shaedrich May 22, 2024
937c90e
refactor(code-samples): 📝 Revert non-pony code samples
shaedrich May 21, 2024
0bc061c
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
3 changes: 2 additions & 1 deletion .github/linters/.markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"MD007": { "indent": 4 },
"MD013": false,
"MD026": false
"MD026": false,
"MD042": false
}
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
32 changes: 32 additions & 0 deletions docs/assets/snippets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @param {MouseEvent} evt
*/
async function runSnippetInline(evt) {
evt.preventDefault();
const snippetRes = await fetch(`https://raw.githubusercontent.com/ponylang/pony-tutorial/main/code-samples/${evt.target.dataset.snippet}`)
const snippetCode = await snippetRes.text()
const evaluateRes = await fetch('https://playground.ponylang.io/evaluate.json', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"code": snippetCode,
"separate_output": true,
"color": true,
"branch": "release"
})
})
const json = await evaluateRes.json()
evt.target.previousElementSibling.querySelector('pre').append(Object.assign(document.create('pre'), {
innerHTML: json.success ? json.stdout : json.compiler,
}))
}

document$.subscribe(function() {
const inlineRunButtons = document.querySelectorAll('.md-button[data-snippet]')

for (const button of inlineRunButtons) {
button.addEventListener('click', runSnippetInline)
}
})
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) =>
^
```

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 inline](#){ .md-button .md-button--primary data-snippet="hello-world-main.pony" }

## Compiling the program

Now compile it:
Expand Down
7 changes: 7 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ repo_url: https://github.com/ponylang/pony-tutorial/
site_url: https://tutorial.ponylang.io/
use_directory_urls: false

extra_javascript:
- assets/snippets.js

extra:
generator: false
social:
Expand All @@ -25,6 +28,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