Skip to content

Commit 4794fa6

Browse files
committed
docs: update action.
1 parent 47f3731 commit 4794fa6

2 files changed

Lines changed: 32 additions & 30 deletions

File tree

.github/workflows/sync-docs.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ jobs:
3333
3434
- name: Sync Files to Website Repo
3535
run: |
36+
# Sync MISRA data and shortcodes
37+
mkdir -p website/docs.zenc-lang.org/data/
38+
mkdir -p website/docs.zenc-lang.org/templates/shortcodes/
39+
rsync -avz docs-repo/site/data/ website/docs.zenc-lang.org/data/
40+
rsync -avz docs-repo/site/templates/shortcodes/ website/docs.zenc-lang.org/templates/shortcodes/
41+
3642
# Sync Standard Library (localized)
3743
mkdir -p website/docs.zenc-lang.org/content/std/
3844
rsync -avz --delete --exclude='_index*.md' docs-repo/std/ website/docs.zenc-lang.org/content/std/
@@ -93,5 +99,5 @@ jobs:
9399
cd website
94100
git config user.name "github-actions[bot]"
95101
git config user.email "github-actions[bot]@users.noreply.github.com"
96-
git add docs.zenc-lang.org/content/std/ docs.zenc-lang.org/content/examples/rosetta/ docs.zenc-lang.org/content/tour/
102+
git add docs.zenc-lang.org/content/std/ docs.zenc-lang.org/content/examples/rosetta/ docs.zenc-lang.org/content/tour/ docs.zenc-lang.org/data/ docs.zenc-lang.org/templates/
97103
git diff --quiet && git diff --staged --quiet || (git commit -m "docs: auto-sync documentation and rosetta examples" && git pull --rebase origin main && git push)

reference/16-misra-rules.md

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ These rules are unique to Zen C. Each rule is checked when `--misra` is active.
4040
Forbids `raw { }` blocks that bypass the transpiler.
4141

4242
```zc
43-
// ❌ Violation:
43+
// Bad:
4444
fn main() {
4545
raw { int x = 10; }
4646
}
4747
48-
// ✅ Fix: use native Zen C constructs
48+
// Good:
4949
fn main() {
5050
let x = 10;
5151
}
@@ -56,10 +56,10 @@ fn main() {
5656
Forbids `plugin ... end` blocks, which execute arbitrary build-time code.
5757

5858
```zc
59-
// ❌ Violation:
59+
// Bad:
6060
plugin my_plugin
6161
62-
// ✅ Fix: implement functionality as a regular function or import a library
62+
// Good:
6363
import "std/some_module.zc"
6464
```
6565

@@ -70,16 +70,15 @@ Forbids the `_` wildcard in `match` on enum types -- all variants must be handle
7070
```zc
7171
enum Color { Red; Green; Blue; }
7272
73-
// ❌ Violation:
73+
// Bad -- missing Blue:
7474
fn describe(c: Color) {
7575
match c {
7676
Color::Red => { println "red"; }
7777
Color::Green => { println "green"; }
78-
// Missing Blue -- Zen 1.3
7978
}
8079
}
8180
82-
// ✅ Fix: handle all variants
81+
// Good:
8382
fn describe(c: Color) {
8483
match c {
8584
Color::Red => { println "red"; }
@@ -95,11 +94,11 @@ Forbids C preprocessor directives (`#define`, `#include`, `#if`, etc.).
9594
Use Zen's `import` and `def` instead.
9695

9796
```zc
98-
// ❌ Violation:
97+
// Bad:
9998
#define BUFFER_SIZE 256
10099
#include <stdio.h>
101100
102-
// ✅ Fix:
101+
// Good:
103102
def BUFFER_SIZE = 256;
104103
import "std/io.zc"
105104
```
@@ -110,31 +109,30 @@ The `var` and `const` keywords are deprecated for variable/constant declarations
110109
Use `let` for variables and `def` for compile-time constants.
111110

112111
```zc
113-
// ❌ Violation:
112+
// Bad:
114113
var x = 10;
115114
const MAX = 100;
116115
117-
// ✅ Fix:
116+
// Good:
118117
let x = 10;
119118
def MAX = 100;
120119
```
121120

122-
> The `const` keyword remains valid as a **type qualifier** for C interop
123-
> (e.g., `const int` means "pointer to const int" in FFI declarations).
121+
> `const` remains valid as a **type qualifier** for C interop
122+
> (e.g., `const int` in FFI declarations).
124123
125124
#### Zen 1.8 -- No identifier shadowing
126125

127126
Forbids declaring a name that hides one from an outer scope.
128127

129128
```zc
130-
// ❌ Violation:
131129
let x = 10;
132130
if true {
133-
let x = 20; // shadows outer x
131+
// Bad -- shadows outer x:
132+
let x = 20;
134133
}
135134
136-
// ✅ Fix: use a distinct name
137-
let x = 10;
135+
// Good:
138136
if true {
139137
let inner_x = 20;
140138
}
@@ -146,12 +144,12 @@ Forbids identifiers starting with `__`, `_[A-Z]`, or `_z_`, which are reserved
146144
for the compiler and C implementation.
147145

148146
```zc
149-
// ❌ Violation:
147+
// Bad:
150148
let __my_var = 10;
151149
let _Reserved = 20;
152150
let _z_internal = 30;
153151
154-
// ✅ Fix: use non-reserved names
152+
// Good:
155153
let my_var = 10;
156154
let reserved = 20;
157155
let internal = 30;
@@ -163,17 +161,15 @@ Tuples with **3 or more fields** shall not be used as function return types or
163161
parameters. Use a named struct instead. 2-tuples are exempt.
164162

165163
```zc
166-
// ❌ Violation:
164+
// Bad -- 3-tuple as return type:
167165
fn get_stats() -> (int, int, int) { ... }
168-
169-
// ❌ Violation:
170166
fn process(p: (int, string, bool)) { ... }
171167
172-
// ✅ OK:
168+
// Good -- use a struct:
173169
struct Stats { sum: int; avg: int; max: int; }
174170
fn get_stats() -> Stats { ... }
175171
176-
// OK (2-tuples exempt):
172+
// OK -- 2-tuples are exempt:
177173
fn get_pair() -> (int, int) { ... }
178174
```
179175

@@ -182,14 +178,14 @@ fn get_pair() -> (int, int) { ... }
182178
`string == string` shall not be used. Use `strcmp()` instead.
183179

184180
```zc
185-
// ❌ Violation:
186-
if a == b { ... } // when a, b are string
181+
// Bad (when a, b are string):
182+
if a == b { ... }
187183
188-
// ✅ Fix:
184+
// Good:
189185
if strcmp(a, b) == 0 { ... }
190186
191-
// OK (non-string types):
192-
if x == y { ... } // int, bool, pointer comparisons are safe
187+
// OK -- int, bool, pointer comparisons are safe:
188+
if x == y { ... }
193189
```
194190

195191
## Standard MISRA C:2012 Coverage

0 commit comments

Comments
 (0)