Skip to content

Commit 298c7a8

Browse files
sbryngelsonclaude
andcommitted
Address review: list-based table headers, robust @page/@ref checks
- Build markdown table headers from column lists instead of string concat - Use re.search with MULTILINE for @page detection (handles leading whitespace) - Strip code blocks before scanning for @ref targets (avoids false positives) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5bec893 commit 298c7a8

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

toolchain/mfc/lint_docs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ def check_page_refs(repo_root: Path) -> list[str]:
211211
page_ids = {"citelist"} # Doxygen built-in
212212
for md_file in doc_dir.glob("*.md"):
213213
text = md_file.read_text(encoding="utf-8")
214-
m = re.match(r"@page\s+(\w+)", text)
214+
m = re.search(r"^\s*@page\s+(\w+)", text, flags=re.MULTILINE)
215215
if m:
216216
page_ids.add(m.group(1))
217217

218218
errors = []
219219
for md_file in sorted(doc_dir.glob("*.md")):
220-
text = md_file.read_text(encoding="utf-8")
220+
text = _strip_code_blocks(md_file.read_text(encoding="utf-8"))
221221
rel = md_file.relative_to(repo_root)
222222
for match in REF_RE.finditer(text):
223223
ref_target = match.group(1)

toolchain/mfc/params/generators/docs_gen.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -457,16 +457,13 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man
457457
lines.append("### Patterns")
458458
lines.append("")
459459
# Build header dynamically based on which optional columns are needed
460-
hdr = "| Pattern | Example | Description"
461-
sep = "|---------|---------|------------"
460+
cols = ["Pattern", "Example", "Description"]
462461
if pattern_has_symbols:
463-
hdr += " | Symbol"
464-
sep += "-|-------"
462+
cols.append("Symbol")
465463
if pattern_has_constraints:
466-
hdr += " | Constraints"
467-
sep += "-|------------"
468-
lines.append(hdr + " |")
469-
lines.append(sep + "-|")
464+
cols.append("Constraints")
465+
lines.append("| " + " | ".join(cols) + " |")
466+
lines.append("| " + " | ".join("-" * max(3, len(c)) for c in cols) + " |")
470467

471468
for pattern, examples in sorted(patterns.items()):
472469
example = examples[0]
@@ -499,15 +496,12 @@ def generate_parameter_docs() -> str: # pylint: disable=too-many-locals,too-man
499496
# Check if any param in this family has a math symbol
500497
full_has_symbols = any(get_math_symbol(n) for n, _ in params)
501498

502-
hdr = "| Parameter | Type | Description"
503-
sep = "|-----------|------|------------"
499+
cols = ["Parameter", "Type", "Description"]
504500
if full_has_symbols:
505-
hdr += " | Symbol"
506-
sep += "-|-------"
507-
hdr += " | Constraints"
508-
sep += "-|------------"
509-
lines.append(hdr + " |")
510-
lines.append(sep + "-|")
501+
cols.append("Symbol")
502+
cols.append("Constraints")
503+
lines.append("| " + " | ".join(cols) + " |")
504+
lines.append("| " + " | ".join("-" * max(3, len(c)) for c in cols) + " |")
511505

512506
for name, param in params:
513507
type_str = _type_to_str(param.param_type)

0 commit comments

Comments
 (0)