code: def setup(app):
      RedirectFrom.app = app
      app.add_directive("redirect-from", RedirectFrom)
      app.add_domain(RedirectFromDomain)
      app.connect("build-finished", _generate_redirects)
  
      metadata = {"parallel_read_safe": True}
      return metadata
  
file_path: matplotlib/doc/sphinxext/redirect_from.py
imports: from pathlib import Path
  from docutils.parsers.rst import Directive
  from sphinx.domains import Domain
  from sphinx.util import logging
label_desc: Use image node_id 1 for calling a global function with example usage: setup(app) and returns: metadata