Skip to content

Commit caae6e2

Browse files
authored
[1/?] Add ability to run code examples in the playground: Move code samples to separate files (#544)
* top-level `/code-samples` directory * flat structure within `/code-samples` * file names within `/code-samples` having the page name, they are _primarily_ used in as a prefix * a few files only consist of said prefix * file names consist of `[a-z-]` * code samples are embedded, using the [snippet](https://squidfunk.github.io/mkdocs-material/reference/code-blocks/#embedding-external-files) feature with the two dashes each syntax (`--8<--`) * code samples are reused when the same code is used elsewhere or lines from it ([snippet lines](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/#snippet-lines) syntax). Code sample reuse, that could only be achieved by the [block format](https://facelessuser.github.io/pymdown-extensions/extensions/snippets/#block-format) is not done * code samples currently have no new line at EOF * we currently have code samples in the following languages: * pony (_see below_) * Bash (`.sh`; 13) * C (9) * Error (`.txt`; 3) = 313 code samples, 298 unique snippets
1 parent b3e0fe4 commit caae6e2

File tree

341 files changed

+2509
-2239
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

341 files changed

+2509
-2239
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
/site
88

99
# Caches and logs
10-
*.log
10+
*.log
11+
12+
# vscode
13+
/.vscode

code-samples/actors-behaviors.pony

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
actor Aardvark
2+
let name: String
3+
var _hunger_level: U64 = 0
4+
5+
new create(name': String) =>
6+
name = name'
7+
8+
be eat(amount: U64) =>
9+
_hunger_level = _hunger_level - amount.min(_hunger_level)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
actor Main
2+
new create(env: Env) =>
3+
call_me_later(env)
4+
env.out.print("This is printed first")
5+
6+
be call_me_later(env: Env) =>
7+
env.out.print("This is printed last")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun test(a: A) =>
2+
var b: A! = a
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun test(a: Wombat iso): Wombat iso^ =>
2+
consume a
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun test(a: Wombat iso) =>
2+
var b: Wombat tag = a // Allowed!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun test(a: Wombat iso) =>
2+
var b: Wombat iso = a // Not allowed!
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun test(a: Wombat trn) =>
2+
var b: Wombat box = a // Allowed!
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class \nosupertype\ Empty
2+
3+
class Foo
4+
fun foo[A: Any](a: (A | Empty val)) =>
5+
match consume a
6+
| let a': A => None
7+
end
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Empty
2+
3+
class Foo
4+
fun foo[A: Any](a: (A | Empty val)) =>
5+
match consume a
6+
| let a': A => None
7+
end

0 commit comments

Comments
 (0)