code: def setup(app):
      setup.app = app
  
      # Add visit/depart methods to HTML-Translator:
      def visit_latex_math_html(self, node):
          source = self.document.attributes["source"]
          self.body.append(latex2html(node, source))
  
      def depart_latex_math_html(self, node):
          pass
  
      # Add visit/depart methods to LaTeX-Translator:
      def visit_latex_math_latex(self, node):
          inline = isinstance(node.parent, nodes.TextElement)
          if inline:
              self.body.append("$%s$" % node["latex"])
          else:
              self.body.extend(
                  [
                      "\\begin{equation}",
                      node["latex"],
                      "\\end{equation}",
                  ]
              )
  
      def depart_latex_math_latex(self, node):
          pass
  
      app.add_node(
          latex_math,
          html=(visit_latex_math_html, depart_latex_math_html),
          latex=(visit_latex_math_latex, depart_latex_math_latex),
      )
      app.add_role("mathmpl", math_role)
      app.add_directive(
          "mathmpl", math_directive, True, (0, 0, 0), **options_spec
      )
      if sphinx.version_info < (1, 8):
          app.add_role("math", math_role)
          app.add_directive(
              "math", math_directive, True, (0, 0, 0), **options_spec
          )
  
      metadata = {
          "parallel_read_safe": True,
          "parallel_write_safe": True,
      }
      return metadata
  
file_path: catboost/contrib/python/matplotlib/py2/matplotlib/sphinxext/mathmpl.py
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  import hashlib
  import os
  import sys
  import warnings
  from docutils import nodes
  from docutils.parsers.rst import directives
  import sphinx
  from matplotlib import rcParams
  from matplotlib.mathtext import MathTextParser
label_desc: Use image node_id 6 for calling a global function with example usage: setup(app) and returns: metadata