class_docstr: A mutable DOM element that displays code as HTML.
class_docstr_tok: ["A","mutable","DOM","element","that","displays","code","as","HTML","."]
docstr: Updates the code viewer to use new code.
docstr_tok: ["Updates","the","code","viewer","to","use","new","code","."]
code: def update_code(self, code_, highlights, *, linenostart: int = 1):
      """Updates the code viewer to use new code."""
      self._code = code_
      self._view.clear()
      code_, css_ = self._highlight_code(
          self._code, highlights, linenostart
      )
      uuid_ = uuid.uuid4()
      code_div = colab_lib.div(
          colab_lib.css(css_),
          code_,
          id=f"code-{uuid_}",
          style=colab_lib.style(
              {
                  "max-height": "500px",
                  "overflow-y": "scroll",
                  "background-color": "var(--colab-border-color)",
                  "padding": "5px 5px 5px 5px",
              }
          ),
      )
      if highlights:
          percent_scroll = highlights[0] / len(self._code.split("\n"))
      else:
          percent_scroll = 0.0
      self.update(code_div)
      # Scroll to where the line is
      output.eval_js(
          """
      console.log("{id}")
      var elem = document.getElementById("{id}")
      var maxScrollPosition = elem.scrollHeight - elem.clientHeight;
      elem.scrollTop = maxScrollPosition * {percent_scroll}
      """.format(
              id=f"code-{uuid_}", percent_scroll=percent_scroll
          )
      )
  
imports: from __future__ import annotations
  import html
  import inspect
  import traceback
  import uuid
  from jax._src.debugger import colab_lib
  from jax._src.debugger import core
  from jax._src.debugger import cli_debugger
label_desc: Use image node_id 7 for calling the CodeViewer obj's underlying member method code with example usage: obj.update_code(code_, highlights) without return types