class_docstr: A directive to collect all lexers/formatters/filters and generate
  autoclass directives for them.
class_docstr_tok: ["A","directive","to","collect","all","lexers\/formatters\/filters","and","generate","autoclass","directives","for","them","."]
code: def document_lexers(self):
      from pygments.lexers._mapping import LEXERS
      import pygments
      import inspect
      import pathlib
  
      out = []
      modules = {}
      moduledocstrings = {}
      for classname, data in sorted(LEXERS.items(), key=lambda x: x[0]):
          module = data[0]
          mod = __import__(module, None, None, [classname])
          self.filenames.add(mod.__file__)
          cls = getattr(mod, classname)
          if not cls.__doc__:
              print(
                  "Warning: %s does not have a docstring." % classname
              )
          docstring = cls.__doc__
          if isinstance(docstring, bytes):
              docstring = docstring.decode("utf8")
  
          example_file = getattr(cls, "_example", None)
          if example_file:
              p = (
                  pathlib.Path(
                      inspect.getabsfile(pygments)
                  ).parent.parent
                  / "tests"
                  / "examplefiles"
                  / example_file
              )
              content = p.read_text(encoding="utf-8")
              if not content:
                  raise Exception(
                      f"Empty example file '{example_file}' for lexer "
                      f"{classname}"
                  )
  
              if data[2]:
                  lexer_name = data[2][0]
                  docstring += "\n\n    .. admonition:: Example\n"
                  docstring += (
                      f"\n      .. code-block:: {lexer_name}\n\n"
                  )
                  for line in content.splitlines():
                      docstring += f"          {line}\n"
  
          modules.setdefault(module, []).append(
              (
                  classname,
                  ", ".join(data[2]) or "None",
                  ", ".join(data[3])
                  .replace("*", "\\*")
                  .replace("_", "\\")
                  or "None",
                  ", ".join(data[4]) or "None",
                  docstring,
              )
          )
          if module not in moduledocstrings:
              moddoc = mod.__doc__
              if isinstance(moddoc, bytes):
                  moddoc = moddoc.decode("utf8")
              moduledocstrings[module] = moddoc
  
      for module, lexers in sorted(modules.items(), key=lambda x: x[0]):
          if moduledocstrings[module] is None:
              raise Exception("Missing docstring for %s" % (module,))
          heading = (
              moduledocstrings[module]
              .splitlines()[4]
              .strip()
              .rstrip(".")
          )
          out.append(MODULEDOC % (module, heading, "-" * len(heading)))
          for data in lexers:
              out.append(LEXERDOC % data)
  
      return "".join(out)
  
file_path: catboost/contrib/python/Pygments/py3/pygments/sphinxext.py
imports: import sys
  from docutils import nodes
  from docutils.statemachine import ViewList
  from docutils.parsers.rst import Directive
  from sphinx.util.nodes import nested_parse_with_titles
label_desc: Use image node_id 3 for calling the PygmentsDoc obj's underlying member method code with example usage: obj.document_lexers() and returns: str