INNER CODE UNIT · Python
format
wasm3/wasm3 · extra/format.py:304
def format(self, text, path):
"""`text` through clang-format, between the pre-passes and the post-passes."""
text, kept = self.protect_verbatim(text)
text = self.hide_sidebars(text)
proc = subprocess.run(
[
self.NAME,
"--assume-filename=" + path,
"--style=file:" + self.config_for(path),
],
input=text,
capture_output=True,
text=True,
check=False,
)
if proc.returncode != 0:
raise FormatterError(f"{self.NAME} failed on {path}:\n{proc.stderr}")
# rehoist changes the width of the code ahead of a sidebar, so the sidebar goes