(app, pagename, templatename, context, doctree)
| 440 | |
| 441 | |
| 442 | def html_page_context(app, pagename, templatename, context, doctree): |
| 443 | # Check if the page is in gallery directories |
| 444 | for gallery_dir in sphinx_gallery_conf["gallery_dirs"]: |
| 445 | if pagename.startswith(gallery_dir): |
| 446 | # Get corresponding examples directory |
| 447 | examples_dir = sphinx_gallery_conf["examples_dirs"][ |
| 448 | sphinx_gallery_conf["gallery_dirs"].index(gallery_dir) |
| 449 | ] |
| 450 | |
| 451 | # Calculate relative path within the gallery |
| 452 | rel_path = ( |
| 453 | pagename[len(gallery_dir) + 1 :] if pagename != gallery_dir else "" |
| 454 | ) |
| 455 | |
| 456 | # Check for .py file in examples directory |
| 457 | py_path = os.path.join(app.srcdir, examples_dir, rel_path + ".py") |
| 458 | |
| 459 | # If a .py file exists, this page was generated from Python |
| 460 | if os.path.exists(py_path): |
| 461 | context["display_github"] = False |
| 462 | return |
| 463 | |
| 464 | # Enable for all other pages |
| 465 | context["display_github"] = True |
| 466 | |
| 467 | |
| 468 | def setup(app): |
nothing calls this directly
no outgoing calls
no test coverage detected