Skip to content

Commit 2f95da3

Browse files
sbryngelsonclaude
andcommitted
Wire constraint doc generation into ./mfc.sh generate
Previously case_constraints.md and physics_constraints.md were only generated via CMake (docs/gen_constraints.sh), so the contributing.md instruction to run ./mfc.sh generate was wrong. Now ./mfc.sh generate produces all 7 auto-generated files, and --check mode validates them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ddf10e4 commit 2f95da3

2 files changed

Lines changed: 28 additions & 17 deletions

File tree

toolchain/mfc/gen_case_constraints_docs.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,13 @@ def _render_cond_parts(trigger_str, cond_dict):
789789
# Main
790790
# ---------------------------------------------------------------------------
791791

792-
def main() -> None:
792+
def main(as_string: bool = False) -> str:
793+
"""Generate case constraints documentation. Returns markdown string."""
793794
analysis = analyze_case_validator(CASE_VALIDATOR_PATH)
794795
md = render_markdown(analysis["rules"])
795-
print(md)
796+
if not as_string:
797+
print(md)
798+
return md
796799

797800

798801
if __name__ == "__main__":

toolchain/mfc/generate.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,21 @@ def _check_or_write(path: Path, content: str, check_mode: bool) -> bool:
3434
return True
3535

3636

37+
def _constraint_docs(docs_dir: Path) -> list:
38+
"""Generate constraint documentation files."""
39+
from .gen_case_constraints_docs import main as gen_case_constraints
40+
from .gen_physics_docs import render as render_physics
41+
from .params.ast_analyzer import analyze_case_validator
42+
43+
validator_path = Path(MFC_ROOT_DIR) / "toolchain" / "mfc" / "case_validator.py"
44+
rules = analyze_case_validator(validator_path)["rules"]
45+
46+
return [
47+
(docs_dir / "case_constraints.md", gen_case_constraints(as_string=True)),
48+
(docs_dir / "physics_constraints.md", render_physics(rules)),
49+
]
50+
51+
3752
def generate():
3853
"""Regenerate completion scripts and optionally JSON schema."""
3954
from .params.generators.json_schema_gen import generate_json_schema
@@ -52,25 +67,18 @@ def generate():
5267
completions_dir.mkdir(exist_ok=True)
5368
docs_dir.mkdir(exist_ok=True)
5469

55-
# Generate CLI files
56-
cli_files = [
70+
# Generate all derived files
71+
files = [
5772
(completions_dir / "mfc.bash", generate_bash_completion(MFC_CLI_SCHEMA)),
5873
(completions_dir / "_mfc", generate_zsh_completion(MFC_CLI_SCHEMA)),
5974
(docs_dir / "cli-reference.md", generate_cli_reference(MFC_CLI_SCHEMA)),
60-
]
61-
62-
# Generate parameter files
63-
schema = generate_json_schema(include_descriptions=True)
64-
schema_content = json.dumps(schema, indent=2)
65-
params_content = generate_parameter_docs()
66-
67-
param_files = [
68-
(Path(MFC_ROOT_DIR) / "toolchain" / "mfc-case-schema.json", schema_content),
69-
(docs_dir / "parameters.md", params_content),
70-
]
75+
(Path(MFC_ROOT_DIR) / "toolchain" / "mfc-case-schema.json",
76+
json.dumps(generate_json_schema(include_descriptions=True), indent=2)),
77+
(docs_dir / "parameters.md", generate_parameter_docs()),
78+
] + _constraint_docs(docs_dir)
7179

7280
all_ok = True
73-
for path, content in cli_files + param_files:
81+
for path, content in files:
7482
if not _check_or_write(path, content, check_mode):
7583
all_ok = False
7684

@@ -79,7 +87,7 @@ def generate():
7987

8088
if not check_mode:
8189
cons.print()
82-
cons.print("[bold]Files regenerated from cli/commands.py and params/definitions.py[/bold]")
90+
cons.print("[bold]Files regenerated from cli/commands.py, params/definitions.py, and case_validator.py[/bold]")
8391

8492

8593
def _generate_json_schema():

0 commit comments

Comments
 (0)