code: def add_binder_url_for_page(
      app,
      pagename: str,
      templatename: str,
      context,
      doctree,
  ):
      # First decide if we'll insert any links
      path = app.env.doc2path(pagename)
      extension = Path(path).suffix
      binder_url_config = app.config["binder_url_config"]
  
      repo_url = binder_url_config["repo_url"]
  
      # Parse the repo parts from the URL
      org, repo = _split_repo_url(repo_url)
      if org is None and repo is None:
          # Skip the rest because the repo_url isn't right
          return
  
      branch = binder_url_config["branch"]
  
      # Check if we have a non-ipynb file, but an ipynb of same name exists
      # If so, we'll use the ipynb extension instead of the text extension
      if (
          extension != ".ipynb"
          and Path(path).with_suffix(".ipynb").exists()
      ):
          extension = ".ipynb"
      elif extension != ".ipynb":
          return
  
      # If this is an excluded notebook, then skip it.
      if Path(path).name in app.config["execution_excludepatterns"]:
          return
  
      # Construct a path to the file relative to the repository root
      book_relpath = binder_url_config["path_to_docs"]
      if book_relpath != "":
          book_relpath += "/"
      path_rel_repo = f"{book_relpath}{pagename}{extension}"
  
      url = (
          f"https://mybinder.org/v2/gh/{org}/{repo}/{branch}?"
          f"filepath={path_rel_repo}"
      )
      context["binder_url"] = url
  
file_path: vowpal_wabbit/python/docs/source/conf.py
imports: import os
  import sys
  import vowpalwabbit
  from pathlib import Path
label_desc: Use image node_id 1 for calling a global function with example usage: add_binder_url_for_page(app, pagename, templatename, context, doctree) without return types