openscad-parser 2.4.7__tar.gz → 2.4.8__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/PKG-INFO +1 -1
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/pyproject.toml +1 -1
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/pretty_print.py +21 -1
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/README.rst +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/__init__.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/__init__.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/builder.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/nodes.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/scope.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/serialization.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/ast/source_map.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/cli.py +0 -0
- {openscad_parser-2.4.7 → openscad_parser-2.4.8}/src/openscad_parser/grammar.py +0 -0
|
@@ -47,7 +47,27 @@ def to_openscad(nodes: list[ASTNode], indent_width: int = 4) -> str:
|
|
|
47
47
|
parts.append("")
|
|
48
48
|
parts.append(_fmt_node(node, 0, indent_width))
|
|
49
49
|
prev_complex = is_complex
|
|
50
|
-
return "\n".join(parts)
|
|
50
|
+
return _coalesce_paren_bracket("\n".join(parts))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _coalesce_paren_bracket(text: str) -> str:
|
|
54
|
+
"""Join consecutive lines where one is a bare ')' and the next starts with '['."""
|
|
55
|
+
lines = text.split("\n")
|
|
56
|
+
result = []
|
|
57
|
+
i = 0
|
|
58
|
+
while i < len(lines):
|
|
59
|
+
if (
|
|
60
|
+
i + 1 < len(lines)
|
|
61
|
+
and lines[i].strip() == ")"
|
|
62
|
+
and lines[i + 1].lstrip().startswith("[")
|
|
63
|
+
):
|
|
64
|
+
indent = len(lines[i]) - len(lines[i].lstrip())
|
|
65
|
+
result.append(" " * indent + ") " + lines[i + 1].lstrip())
|
|
66
|
+
i += 2
|
|
67
|
+
else:
|
|
68
|
+
result.append(lines[i])
|
|
69
|
+
i += 1
|
|
70
|
+
return "\n".join(result)
|
|
51
71
|
|
|
52
72
|
|
|
53
73
|
# Line length beyond which call arguments are formatted one-per-line.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|