Skip to content

Commit 957422f

Browse files
committed
Update spec
1 parent 4b49265 commit 957422f

File tree

1 file changed

+49
-4
lines changed

1 file changed

+49
-4
lines changed

docs/pages/spec.mdx

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -666,15 +666,27 @@ optional_file = Path("./optional.zen", allow_not_exist=True)
666666
- `path`: String path to resolve (supports any LoadSpec format)
667667
- `allow_not_exist`: Optional boolean (default: False). If True, allows non-existent paths. Can only be used with local path LoadSpecs, not package/GitHub/GitLab specs.
668668

669-
### error(msg)
669+
### error(msg, suppress=False, kind=None)
670670

671-
Raises a runtime error with the given message.
671+
Raises a runtime error with the given message. With `suppress=True`, the error is rendered but doesn't stop evaluation or fail the build.
672672

673673
```python
674+
# Basic error (stops evaluation)
674675
if not condition:
675676
error("Condition failed")
677+
678+
# Suppressed error (rendered but doesn't fail build)
679+
error("Non-critical issue detected", suppress=True)
680+
681+
# Categorized error for filtering
682+
error("Voltage out of range", suppress=True, kind="electrical.voltage")
676683
```
677684

685+
**Parameters:**
686+
- `msg`: Error message (required)
687+
- `suppress`: If True, renders diagnostic but doesn't stop evaluation or fail build (default: False)
688+
- `kind`: Optional diagnostic kind for filtering/categorization (e.g., "electrical.voltage_mismatch")
689+
678690
### check(condition, msg)
679691

680692
Checks a condition and raises an error if false.
@@ -684,15 +696,48 @@ check(voltage > 0, "Voltage must be positive")
684696
check(len(pins) == 8, "Expected 8 pins")
685697
```
686698

687-
### warn(msg)
699+
### warn(msg, suppress=False, kind=None)
688700

689701
Emits a warning diagnostic with the given message and continues execution. Unlike `error()`, this does not stop evaluation.
690702

691703
```python
704+
# Basic warning
692705
warn("Component value is outside typical range")
693-
warn("This configuration may have performance implications")
706+
707+
# Suppressed warning (won't fail build with -Dwarnings)
708+
warn("Optimization suggestion", suppress=True)
709+
710+
# Categorized warning for filtering
711+
warn("High current detected", kind="electrical.current")
712+
warn("Trace too narrow", kind="layout.spacing")
694713
```
695714

715+
**Parameters:**
716+
- `msg`: Warning message (required)
717+
- `suppress`: If True, won't cause build failure with `-Dwarnings` flag (default: False)
718+
- `kind`: Optional diagnostic kind for filtering/categorization (e.g., "electrical.overvoltage")
719+
720+
**Diagnostic Kinds:**
721+
722+
The `kind` parameter enables hierarchical categorization of diagnostics for filtering at the CLI level:
723+
724+
```python
725+
# Categorize by domain
726+
warn("Voltage exceeds spec", kind="electrical")
727+
warn("Trace spacing too narrow", kind="layout")
728+
warn("Missing part number", kind="bom")
729+
730+
# Hierarchical kinds use dot-separated segments
731+
warn("Overvoltage detected", kind="electrical.voltage.overvoltage")
732+
warn("Trace clearance violation", kind="layout.spacing.clearance")
733+
```
734+
735+
Kinds can be suppressed at build time using the `-S` flag with hierarchical matching:
736+
- `-S electrical` suppresses all electrical.* warnings
737+
- `-S electrical.voltage` suppresses electrical.voltage.* warnings
738+
- `-S warnings` suppresses all warnings regardless of kind
739+
- `-S errors` suppresses all errors regardless of kind
740+
696741
### add_property(name, value)
697742

698743
Adds a property to the current module instance.

0 commit comments

Comments
 (0)