Skip to content

Commit 04c99c8

Browse files
sbryngelsonclaude
andcommitted
Fix value_labels rendering, substring matching, and misleading comment
- docs_gen.py: Render value_labels in Constraints column instead of skipping them, fixing 12 params that lost valid-value info - case_validator.py: Use word-boundary regex for CONSTRAINTS hint matching to prevent false matches on short param names - ast_analyzer.py: Use word-boundary regex for 'must be 1' pattern to avoid matching 'must be 10', 'must be 100', etc. - definitions.py: Fix misleading comment in _lookup_hint() Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 13010c8 commit 04c99c8

4 files changed

Lines changed: 16 additions & 8 deletions

File tree

toolchain/mfc/case_validator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# pylint: disable=too-many-lines
1515
# Justification: Comprehensive validator covering all MFC parameter constraints
1616

17+
import re
1718
from typing import Dict, Any, List, Set
1819
from functools import lru_cache
1920
from .common import MFCException
@@ -1937,7 +1938,7 @@ def _format_errors(self) -> str:
19371938

19381939
# Auto-generate hints from CONSTRAINTS with value_labels
19391940
for param_name, constraint in CONSTRAINTS.items():
1940-
if param_name not in err_lower:
1941+
if not re.search(r'\b' + re.escape(param_name) + r'\b', err_lower):
19411942
continue
19421943
choices = constraint.get("choices")
19431944
if not choices:

toolchain/mfc/params/ast_analyzer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from __future__ import annotations
1010

1111
import ast
12+
import re
1213
from dataclasses import dataclass, field
1314
from pathlib import Path
1415
from typing import Dict, List, Optional, Set
@@ -675,7 +676,7 @@ def classify_message(msg: str) -> str:
675676
or "must be >=" in text
676677
or "must be odd" in text
677678
or "divisible by" in text
678-
or "must be 1" in text
679+
or re.search(r"must be 1\b", text) is not None
679680
or "must be 'T' or 'F'" in text
680681
):
681682
return "range"

toolchain/mfc/params/definitions.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,10 @@ def _lookup_hint(name):
436436
return ""
437437
# Compound name: extract family and attribute
438438
prefix, attr_full = name.split('%', 1)
439-
# Normalize family: "bc_x" → "bc", "patch_bc(1)" → "patch_bc"
440-
family = re.sub(r'[_(].*', '', prefix) # "bc_x" → "bc", "patch_bc" stays
439+
# Normalize family: "bc_x" → "bc", "patch_bc(1)" → "patch"
440+
family = re.sub(r'[_(].*', '', prefix)
441441
if family not in HINTS:
442-
# Try with underscore-joined prefix: "simplex_params" stays
442+
# Fallback: keep underscores — "patch_bc" → "patch_bc", "simplex_params" → "simplex_params"
443443
family = re.match(r'^[a-zA-Z_]+', prefix).group(0)
444444
if family not in HINTS:
445445
return ""

toolchain/mfc/params/generators/docs_gen.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,20 @@ def _type_to_str(param_type: ParamType) -> str:
103103

104104

105105
def _format_constraints(param) -> str:
106-
"""Format constraints as readable string, skipping choices already shown via value_labels."""
106+
"""Format constraints as readable string with value labels when available."""
107107
if not param.constraints:
108108
return ""
109109

110110
parts = []
111111
c = param.constraints
112-
if "choices" in c and "value_labels" not in c:
113-
parts.append(f"Values: {c['choices']}")
112+
if "choices" in c:
113+
labels = c.get("value_labels", {})
114+
if labels:
115+
items = [f"{v}={labels[v]}" if v in labels else str(v)
116+
for v in c["choices"]]
117+
parts.append(", ".join(items))
118+
else:
119+
parts.append(f"Values: {c['choices']}")
114120
if "min" in c:
115121
parts.append(f"Min: {c['min']}")
116122
if "max" in c:

0 commit comments

Comments
 (0)