From 581390933d4604fd0bc702179a6b16fad7fb4667 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Fri, 3 Jul 2026 22:21:33 +0200 Subject: [PATCH] Improved docs (allman syntax) --- content/docs/guide/control-flow.mdx | 28 +++++++++++++------- content/docs/guide/functions.mdx | 6 +---- content/docs/guide/generics.mdx | 10 ++++--- content/docs/guide/patterns.mdx | 6 ++--- content/docs/guide/structs-enums.mdx | 15 +++++++---- content/docs/guide/traits-impls.mdx | 18 ++++++++----- content/docs/internals/semantic-analysis.mdx | 7 ++--- content/docs/internals/transpiler.mdx | 5 ++-- 8 files changed, 57 insertions(+), 38 deletions(-) diff --git a/content/docs/guide/control-flow.mdx b/content/docs/guide/control-flow.mdx index effa561..33d0390 100644 --- a/content/docs/guide/control-flow.mdx +++ b/content/docs/guide/control-flow.mdx @@ -7,17 +7,20 @@ icon: ArrowLeftRight ### If/Else ```mist -if condition { +if condition +{ // body -} else if other_condition { +} +else if other_condition +{ // body -} else { +} +else +{ // body } ``` -Conditions must be parenthesized: `if (expr) { }` or `if expr_no_struct { }` (struct literals require parentheses). - Used as an expression: ```mist @@ -27,7 +30,8 @@ let x = if true { 1 } else { 2 }; ### While ```mist -while condition { +while condition +{ // body } ``` @@ -35,11 +39,13 @@ while condition { ### For ```mist -for pattern in iterator { +for pattern in iterator +{ // body } -for i in 0 .. 10 { +for i in 0 .. 10 +{ // body } ``` @@ -47,7 +53,8 @@ for i in 0 .. 10 { ### C-Style For ```mist -for (let mut i = 0; i < 10; i++) { +for (let mut i = 0; i < 10; i++) +{ // body } ``` @@ -55,7 +62,8 @@ for (let mut i = 0; i < 10; i++) { ### Loop ```mist -loop { +loop +{ // infinite loop } ``` diff --git a/content/docs/guide/functions.mdx b/content/docs/guide/functions.mdx index b45507a..8cfa5b0 100644 --- a/content/docs/guide/functions.mdx +++ b/content/docs/guide/functions.mdx @@ -42,13 +42,9 @@ unsafe i32 dangerous() } ``` -Function syntax: `[pub] [void | ] []() [override] { }` - -Functions use **Allman brace style** (opening brace on the next line). - ### Self Parameter -Methods can take `self`, `mut self`, `&self`, `&mut self` additionally with lifetimes: +Methods can take `self`, `mut self`, `&self`, `&mut self`, and `&'a self` / `&'a mut self` with lifetimes: ```mist pub void set_value(&mut self, i32 v) diff --git a/content/docs/guide/generics.mdx b/content/docs/guide/generics.mdx index 458f696..ba3d6a1 100644 --- a/content/docs/guide/generics.mdx +++ b/content/docs/guide/generics.mdx @@ -12,15 +12,17 @@ T id(T x) } // Generic struct -struct Pair { +struct Pair +{ A first, B second, } // Generic enum -enum Result { - Ok(T), - Err(E), +enum Result +{ + Ok(T); + Err(E); } // Generic with trait bounds diff --git a/content/docs/guide/patterns.mdx b/content/docs/guide/patterns.mdx index 05f76d5..57a11e4 100644 --- a/content/docs/guide/patterns.mdx +++ b/content/docs/guide/patterns.mdx @@ -25,11 +25,11 @@ match value { // Named tuple patterns (newtype) let MyType(value) = my_var; -// Wildcard / etc +// Wildcard / rest let _ = get_side_effect(); match x { - 1 => ..., - .. => ..., // rest / etc + 1 => expr, + .. => expr, // rest / etc } // Mutable binding in pattern diff --git a/content/docs/guide/structs-enums.mdx b/content/docs/guide/structs-enums.mdx index e047bb3..05922f3 100644 --- a/content/docs/guide/structs-enums.mdx +++ b/content/docs/guide/structs-enums.mdx @@ -7,12 +7,14 @@ icon: Box ### Structs ```mist -pub struct Point { +pub struct Point +{ i32 x, i32 y, } -pub struct Generic { +pub struct Generic +{ T value, } ``` @@ -20,7 +22,8 @@ pub struct Generic { Fields can be public or private: ```mist -struct User { +struct User +{ pub str& name, i32 age, // private } @@ -29,12 +32,14 @@ struct User { ### Enums ```mist -pub enum Option { +pub enum Option +{ Some(T), None, } -pub enum Message { +pub enum Message +{ Quit, Move(i32, i32), Write { str& content, i32 length }, diff --git a/content/docs/guide/traits-impls.mdx b/content/docs/guide/traits-impls.mdx index 4a6370a..022dfbd 100644 --- a/content/docs/guide/traits-impls.mdx +++ b/content/docs/guide/traits-impls.mdx @@ -7,11 +7,13 @@ icon: Puzzle ### Traits ```mist -pub trait Drawable { +pub trait Drawable +{ void draw(&self); } -pub trait Comparable : Eq { +pub trait Comparable : Eq +{ i32 cmp(&self, T other); } ``` @@ -19,7 +21,8 @@ pub trait Comparable : Eq { Trait requirements are specified after `:`: ```mist -trait MyTrait : SuperTrait + OtherTrait { +trait MyTrait : SuperTrait + OtherTrait +{ void required_method(&self); void another(&self); } @@ -28,15 +31,18 @@ trait MyTrait : SuperTrait + OtherTrait { ### Impl Blocks ```mist -impl MyType { +impl MyType +{ void method(&self) { } } -impl Trait for MyType { +impl Trait for MyType +{ void method(&self) { } } -impl GenericTrait for MyType { +impl GenericTrait for MyType +{ void method(&self, T value) { } } ``` diff --git a/content/docs/internals/semantic-analysis.mdx b/content/docs/internals/semantic-analysis.mdx index 0359913..2cc268f 100644 --- a/content/docs/internals/semantic-analysis.mdx +++ b/content/docs/internals/semantic-analysis.mdx @@ -11,9 +11,10 @@ The semantic checker (`semantics.rs`) performs class field initialization analys The primary semantic check ensures all class fields are initialized in the constructor: ```mist -class Player { - i32 health, - str& name, +class Player +{ + i32 health; + str& name; pub constructor(str& name) { diff --git a/content/docs/internals/transpiler.mdx b/content/docs/internals/transpiler.mdx index c7d6256..b25cb75 100644 --- a/content/docs/internals/transpiler.mdx +++ b/content/docs/internals/transpiler.mdx @@ -21,8 +21,9 @@ The transpiler (`transpiler.mist` in `mist_api`) orchestrates the full pipeline. The `Module` struct represents the file-to-module mapping: -```rust -pub class Module { +```mist +pub class Module +{ pub String name; pub PathBuf path; pub Vec children;