code: def pv_html_page_context(
      app, pagename: str, templatename: str, context, doctree
  ) -> None:  # pragma: no cover
      """Add a function that jinja can access for returning an "edit this page" link pointing to `main`.
  
      This is specific to PyVista to ensure that the "edit this page" link always
      goes to the right page, specifically for:
  
      - Gallery examples
      - Autosummary examples (using _autosummary)
  
      """
  
      def fix_edit_link_button(link: str) -> Optional[str]:
          """Transform "edit on github" links to the correct url.
  
          This is specific to PyVista to ensure that the "edit this page" link
          always goes to the right page, specifically for:
  
          - Gallery examples
          - Autosummary examples (using _autosummary)
  
          Parameters
          ----------
          link : str
              The link to the github edit interface.
  
          Returns
          -------
          str
              The link to the tip of the main branch for the same file.
  
          """
          if (
              pagename.startswith("examples")
              and "index" not in pagename
          ):
              # This is a gallery example.
  
              # We can get away with directly using the pagename since "examples"
              # in the pagename is the same as the "examples" directory in the
              # repo
              return f"http://github.com/pyvista/pyvista/edit/main/{pagename}.py"
          elif "_autosummary" in pagename:
              # This is an API example
              fullname = pagename.split("_autosummary")[1][1:]
              return linkcode_resolve(
                  "py",
                  {"module": "pyvista", "fullname": fullname},
                  edit=True,
              )
          else:
              return link
  
      context["fix_edit_link_button"] = fix_edit_link_button
  
imports: import inspect
  import os
  import os.path
  import sys
  from typing import Dict, Optional
label_desc: Use image node_id 2 for calling a global function with example usage: pv_html_page_context(app, pagename, templatename, context, doctree) and returns: str, pagename, str, linkcode_resolve, link