INNER CODE UNIT · Python
sidebar_call_span
wasm3/wasm3 · extra/format.py:353
def sidebar_call_span(self, lines, i, tail):
"""Line count of the sidebar call at lines[i] that reads on as `tail`."""
depth = tail.count("(") - tail.count(")")
n = 1
while depth > 0 and i + n < len(lines):
depth += lines[i + n].count("(") - lines[i + n].count(")")
n += 1
return n
def wrapped_sidebar_span(self, lines, i):
"""Line count of a sidebar whose call runs past the end of lines[i], else 0.
The disguise in hide_sidebars only works on a sidebar that ends on its own line:
a `//` comment cannot carry the continuation, which would be left behind as code
and read as a continuation of the statement, cascading the indent of everything
after it. Only the continuation lines are held back -- the first line still goes
through the run, since it carries the real code, up to and including a brace that
the parse depends on.