class_docstr: Writes a single pyi file
class_docstr_tok: ["Writes","a","single","pyi","file"]
docstr: Return true if any comments were written
docstr_tok: ["Return","true","if","any","comments","were","written"]
code: def _write_comments(self, scl: SourceCodeLocation) -> bool:
      """Return true if any comments were written"""
      if not self._has_comments(scl):
          return False
  
      sci_loc = self.source_code_info_by_scl.get(tuple(scl))
      assert sci_loc is not None
  
      leading_detached_lines = []
      leading_lines = []
      trailing_lines = []
      for leading_detached_comment in sci_loc.leading_detached_comments:
          leading_detached_lines = self._break_text(
              leading_detached_comment
          )
      if sci_loc.leading_comments is not None:
          leading_lines = self._break_text(sci_loc.leading_comments)
      # Trailing comments also go in the header - to make sure it gets into the docstring
      if sci_loc.trailing_comments is not None:
          trailing_lines = self._break_text(sci_loc.trailing_comments)
  
      lines = leading_detached_lines
      if leading_detached_lines and (leading_lines or trailing_lines):
          lines.append("")
      lines.extend(leading_lines)
      lines.extend(trailing_lines)
  
      lines = [
          # Escape triple-quotes that would otherwise end the docstring early.
          line.replace("\\", "\\\\").replace('"""', r"\"\"\"")
          for line in lines
      ]
      if len(lines) == 1:
          line = lines[0]
          if line.endswith(('"', "\\")):
              # Docstrings are terminated with triple-quotes, so if the documentation itself ends in a quote,
              # insert some whitespace to separate it from the closing quotes.
              # This is not necessary with multiline comments
              # because in that case we always insert a newline before the trailing triple-quotes.
              line = line + " "
          self._write_line(f'"""{line}"""')
      else:
          for i, line in enumerate(lines):
              if i == 0:
                  self._write_line(f'"""{line}')
              else:
                  self._write_line(f"{line}")
          self._write_line('"""')
  
      return True
  
imports: from __future__ import annotations
  import sys
  from collections import defaultdict
  from contextlib import contextmanager
  from typing import Any, Callable, Dict, Iterable, Iterator, List, Optional, Set, Sequence, Tuple
  import google.protobuf.descriptor_pb2
  from google.protobuf.compiler import plugin_pb2
  from google.protobuf.internal.containers import RepeatedCompositeFieldContainer
  from google.protobuf.internal.well_known_types import WKTBASES
  from .None import extensions_pb2
label_desc: Use image node_id 9 for calling the PkgWriter obj's underlying member method code with example usage: obj._write_comments(scl) and returns: True, False