From e64107ad75a38c73a5d89f671b3bfefc0eb2582a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:41:51 +0200 Subject: [PATCH 1/3] Show full program in tutorial with highlighted lines --- docs/types/classes.md | 33 ++++++++++++++++++++++++--------- mkdocs.yml | 2 ++ 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/docs/types/classes.md b/docs/types/classes.md index be9f22dd..cc4a297f 100644 --- a/docs/types/classes.md +++ b/docs/types/classes.md @@ -2,9 +2,14 @@ Just like other object-oriented languages, Pony has __classes__. A class is declared with the keyword `class`, and it has to have a name that starts with a capital letter, like this: -```pony ---8<-- "classes-wombat.pony:1:1" -``` +=== "Snippet" + ```pony + --8<-- "classes-wombat.pony:1:1" + ``` +=== "Full program" + ```pony hl_lines="1" + --8<-- "classes-wombat.pony" + ``` __Do all types start with a capital letter?__ Yes! And nothing else starts with a capital letter. So when you see a name in Pony code, you will instantly know whether it's a type or not. @@ -20,9 +25,14 @@ A class is composed of: These are just like fields in C structures or fields in classes in C++, C#, Java, Python, Ruby, or basically any language, really. There are three kinds of fields: `var`, `let`, and `embed` fields. A `var` field can be assigned to over and over again, but a `let` field is assigned to in the constructor and never again. Embed fields will be covered in more detail in the documentation on [variables](/expressions/variables.md). -```pony ---8<-- "classes-wombat.pony:1:3" -``` +=== "Snippet" + ```pony + --8<-- "classes-wombat.pony:1:3" + ``` +=== "Full program" + ```pony hl_lines="1-3" + --8<-- "classes-wombat.pony" + ``` Here, a `Wombat` has a `name`, which is a `String`, and a `_hunger_level`, which is a `U64` (an unsigned 64-bit integer). @@ -50,9 +60,14 @@ Every constructor has to set every field in an object. If it doesn't, the compil Sometimes it's convenient to set a field the same way for all constructors. -```pony ---8<-- "classes-wombat.pony:1:12" -``` +=== "Snippet" + ```pony + --8<-- "classes-wombat.pony:1:12" + ``` +=== "Full program" + ```pony hl_lines="1-12" + --8<-- "classes-wombat.pony" + ``` Here, every `Wombat` begins a little bit thirsty, regardless of which constructor is called. diff --git a/mkdocs.yml b/mkdocs.yml index caed243a..d56ab9d4 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -22,6 +22,8 @@ markdown_extensions: - name: mermaid class: mermaid-experimental format: !!python/name:pymdownx.superfences.fence_code_format + - pymdownx.tabbed: + alternate_style: true - pymdownx.snippets: base_path: ['code-samples'] check_paths: true From 7b5d2467168de9655996d20fdf354d062b13335c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:46:17 +0200 Subject: [PATCH 2/3] Use slugs as tab IDs --- mkdocs.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mkdocs.yml b/mkdocs.yml index d56ab9d4..cf65d696 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -24,6 +24,9 @@ markdown_extensions: format: !!python/name:pymdownx.superfences.fence_code_format - pymdownx.tabbed: alternate_style: true + slugify: !!python/object/apply:pymdownx.slugs.slugify + kwds: + case: lower - pymdownx.snippets: base_path: ['code-samples'] check_paths: true From 83938247117266c7db99bf06250277c041528b51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20H=C3=A4drich?= <11225821+shaedrich@users.noreply.github.com> Date: Wed, 5 Jun 2024 15:48:14 +0200 Subject: [PATCH 3/3] Add exception for markdown lint MD038 --- .github/linters/.markdown-lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/linters/.markdown-lint.yml b/.github/linters/.markdown-lint.yml index 7e403081..886c72b6 100644 --- a/.github/linters/.markdown-lint.yml +++ b/.github/linters/.markdown-lint.yml @@ -1,5 +1,6 @@ { "MD007": { "indent": 4 }, "MD013": false, - "MD026": false + "MD026": false, + "MD038": false }