Format Function definitions (#4951)

This commit is contained in:
Micha Reiser 2023-06-08 18:07:33 +02:00 committed by GitHub
parent 07cc4bcb0f
commit 68969240c5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
79 changed files with 2601 additions and 1223 deletions

View file

@ -77,6 +77,11 @@ for group, group_nodes in nodes_grouped.items():
# )
# src.joinpath(groups[group]).joinpath("mod.rs").write_text(rustfmt(mod_section))
for node in group_nodes:
node_path = src.joinpath(groups[group]).joinpath(f"{to_camel_case(node)}.rs")
# Don't override existing manual implementations
if node_path.exists():
continue
code = f"""
use crate::{{verbatim_text, FormatNodeRule, PyFormatter}};
use ruff_formatter::{{write, Buffer, FormatResult}};
@ -91,9 +96,8 @@ for group, group_nodes in nodes_grouped.items():
}}
}}
""".strip() # noqa: E501
src.joinpath(groups[group]).joinpath(f"{to_camel_case(node)}.rs").write_text(
rustfmt(code)
)
node_path.write_text(rustfmt(code))
# %%
# Generate `FormatRule`, `AsFormat` and `IntoFormat`