forked from genewildish/Mainline
fix: resolve terminal display wobble and effect dimension stability
- Fix TerminalDisplay: add screen clear each frame (cursor home + erase down) - Fix CameraStage: use set_canvas_size instead of read-only viewport properties - Fix Glitch effect: preserve visible line lengths, remove cursor positioning - Fix Fade effect: return original line when fade=0 instead of empty string - Fix Noise effect: use input line length instead of terminal_width - Remove HUD effect from all presets (redundant with border FPS display) - Add regression tests for effect dimension stability - Add docs/ARCHITECTURE.md with Mermaid diagrams - Add mise tasks: diagram-ascii, diagram-validate, diagram-check - Move markdown docs to docs/ (ARCHITECTURE, Refactor, hardware specs) - Remove redundant requirements files (use pyproject.toml) - Add *.dot and *.png to .gitignore Closes #25
This commit is contained in:
49
scripts/render-diagrams.py
Normal file
49
scripts/render-diagrams.py
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Render Mermaid diagrams in markdown files to ASCII art."""
|
||||
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
def extract_mermaid_blocks(content: str) -> list[str]:
|
||||
"""Extract mermaid blocks from markdown."""
|
||||
return re.findall(r"```mermaid\n(.*?)\n```", content, re.DOTALL)
|
||||
|
||||
|
||||
def render_diagram(block: str) -> str:
|
||||
"""Render a single mermaid block to ASCII."""
|
||||
result = subprocess.run(
|
||||
["mermaid-ascii", "-f", "-"],
|
||||
input=block,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode != 0:
|
||||
return f"ERROR: {result.stderr}"
|
||||
return result.stdout
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: render-diagrams.py <markdown-file>")
|
||||
sys.exit(1)
|
||||
|
||||
filename = sys.argv[1]
|
||||
content = open(filename).read()
|
||||
blocks = extract_mermaid_blocks(content)
|
||||
|
||||
print(f"Found {len(blocks)} mermaid diagram(s) in {filename}")
|
||||
print()
|
||||
|
||||
for i, block in enumerate(blocks):
|
||||
# Skip if empty
|
||||
if not block.strip():
|
||||
continue
|
||||
|
||||
print(f"=== Diagram {i + 1} ===")
|
||||
print(render_diagram(block))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
64
scripts/validate-diagrams.py
Normal file
64
scripts/validate-diagrams.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Validate Mermaid diagrams in markdown files."""
|
||||
|
||||
import glob
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
# Diagram types that are valid in Mermaid
|
||||
VALID_TYPES = {
|
||||
"flowchart",
|
||||
"graph",
|
||||
"classDiagram",
|
||||
"sequenceDiagram",
|
||||
"stateDiagram",
|
||||
"stateDiagram-v2",
|
||||
"erDiagram",
|
||||
"gantt",
|
||||
"pie",
|
||||
"mindmap",
|
||||
"journey",
|
||||
"gitGraph",
|
||||
"requirementDiagram",
|
||||
}
|
||||
|
||||
|
||||
def extract_mermaid_blocks(content: str) -> list[tuple[int, str]]:
|
||||
"""Extract mermaid blocks with their positions."""
|
||||
blocks = []
|
||||
for match in re.finditer(r"```mermaid\n(.*?)\n```", content, re.DOTALL):
|
||||
blocks.append((match.start(), match.group(1)))
|
||||
return blocks
|
||||
|
||||
|
||||
def validate_block(block: str) -> bool:
|
||||
"""Check if a mermaid block has a valid diagram type."""
|
||||
if not block.strip():
|
||||
return True # Empty block is OK
|
||||
first_line = block.strip().split("\n")[0]
|
||||
return any(first_line.startswith(t) for t in VALID_TYPES)
|
||||
|
||||
|
||||
def main():
|
||||
md_files = glob.glob("docs/*.md")
|
||||
|
||||
errors = []
|
||||
for filepath in md_files:
|
||||
content = open(filepath).read()
|
||||
blocks = extract_mermaid_blocks(content)
|
||||
|
||||
for i, (_, block) in enumerate(blocks):
|
||||
if not validate_block(block):
|
||||
errors.append(f"{filepath}: invalid diagram type in block {i + 1}")
|
||||
|
||||
if errors:
|
||||
for e in errors:
|
||||
print(f"ERROR: {e}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Validated {len(md_files)} markdown files - all OK")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user