class_docstr: Step through document and build TOC. 
class_docstr_tok: ["Step","through","document","and","build","TOC","."]
code: def add_anchor(self, c: etree.Element, elem_id: str) -> None:
      anchor = etree.Element("a")
      anchor.text = c.text
      anchor.attrib["href"] = "#" + elem_id
      anchor.attrib["class"] = self.anchorlink_class
      c.text = ""
      for elem in c:
          anchor.append(elem)
      while len(c):
          c.remove(c[0])
      c.append(anchor)
  
imports: from __future__ import annotations
  from .None import Extension
  from ..treeprocessors import Treeprocessor
  from ..util import code_escape, parseBoolValue, AMP_SUBSTITUTE, HTML_PLACEHOLDER_RE, AtomicString
  from ..treeprocessors import UnescapeTreeprocessor
  import re
  import html
  import unicodedata
  import xml.etree.ElementTree
  from typing import TYPE_CHECKING, Any, Iterator, MutableSet
label_desc: Use image node_id 5 for calling the TocTreeprocessor obj's underlying member method code with example usage: obj.add_anchor(c, elem_id) without return types