From 3e656b4e3a06406eac3a654747f9b76c536b8bde Mon Sep 17 00:00:00 2001 From: Sivayogeith Umamaheswaran Date: Sat, 26 Jul 2025 09:29:46 +0530 Subject: [PATCH 1/5] DOC: added button to edit on GitHub fixes #39859 --- doc/source/conf.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/source/conf.py b/doc/source/conf.py index f222a228531ff..df918a8a67276 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -270,6 +270,8 @@ "icon": "fa-brands fa-mastodon", }, ], + "secondary_sidebar_items": ["page-toc", "sourcelink", "edit-this-page"], + "use_edit_page_button": True } # Add any paths that contain custom themes here, relative to this directory. @@ -393,6 +395,10 @@ html_context = { "redirects": dict(moved_api_pages), "header": header, + "github_user": "pandas-dev", + "github_repo": "pandas", + "github_version": "main", + "doc_path": "doc/source", } # If false, no module index is generated. From f82cb3d9e1768cee93061f206992093ed9d025fe Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 26 Jul 2025 04:15:43 +0000 Subject: [PATCH 2/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index df918a8a67276..11ce9e515e774 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -271,7 +271,7 @@ }, ], "secondary_sidebar_items": ["page-toc", "sourcelink", "edit-this-page"], - "use_edit_page_button": True + "use_edit_page_button": True, } # Add any paths that contain custom themes here, relative to this directory. From 0156b09f20b03091e0b0ea22c001d43ab6b01bdb Mon Sep 17 00:00:00 2001 From: Sivayogeith Umamaheswaran Date: Wed, 30 Jul 2025 09:17:24 +0530 Subject: [PATCH 3/5] DOC: added exclude_edit_page_button and logic for it to work --- doc/_templates/edit-this-page.html | 17 +++++++++++++++++ doc/source/conf.py | 1 + 2 files changed, 18 insertions(+) create mode 100644 doc/_templates/edit-this-page.html diff --git a/doc/_templates/edit-this-page.html b/doc/_templates/edit-this-page.html new file mode 100644 index 0000000000000..b836d63b6ca6d --- /dev/null +++ b/doc/_templates/edit-this-page.html @@ -0,0 +1,17 @@ +{# Displays a link to the edit interface of the page source in the specified Version Control System. #} +{% if sourcename is defined and theme_use_edit_page_button==true and page_source_suffix and pagename not in exclude_edit_page_button %} + {% set src = sourcename.split('.') %} + +{% endif %} diff --git a/doc/source/conf.py b/doc/source/conf.py index 11ce9e515e774..e4152802d52d4 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -399,6 +399,7 @@ "github_repo": "pandas", "github_version": "main", "doc_path": "doc/source", + "exclude_edit_page_button": ["index"], } # If false, no module index is generated. From 0e9d991b2e61225c84f377debd7f58a5f3da33aa Mon Sep 17 00:00:00 2001 From: Sivayogeith Umamaheswaran Date: Fri, 1 Aug 2025 09:52:10 +0530 Subject: [PATCH 4/5] feat: added show_edit_this_page ext which decides to show the button or not based on the config --- doc/_templates/edit-this-page.html | 2 +- doc/source/conf.py | 8 +++++++- doc/sphinxext/show_edit_this_page.py | 15 +++++++++++++++ 3 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 doc/sphinxext/show_edit_this_page.py diff --git a/doc/_templates/edit-this-page.html b/doc/_templates/edit-this-page.html index b836d63b6ca6d..0c9d9345623d3 100644 --- a/doc/_templates/edit-this-page.html +++ b/doc/_templates/edit-this-page.html @@ -1,5 +1,5 @@ {# Displays a link to the edit interface of the page source in the specified Version Control System. #} -{% if sourcename is defined and theme_use_edit_page_button==true and page_source_suffix and pagename not in exclude_edit_page_button %} +{% if sourcename is defined and theme_use_edit_page_button==true and page_source_suffix and show_edit_this_page %} {% set src = sourcename.split('.') %}
diff --git a/doc/source/conf.py b/doc/source/conf.py index e4152802d52d4..11b6d5c789196 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -69,6 +69,7 @@ "sphinx.ext.mathjax", "sphinx.ext.todo", "nbsphinx", + "show_edit_this_page", ] exclude_patterns = [ @@ -399,7 +400,12 @@ "github_repo": "pandas", "github_version": "main", "doc_path": "doc/source", - "exclude_edit_page_button": ["index"], + "exclude_edit_this_page_pagename": [ + "index" + ], # specific pages, e.g., index, development/index + "exclude_edit_this_page_directory": [ + "api" + ], # all files in a directory, e.g., development, reference } # If false, no module index is generated. diff --git a/doc/sphinxext/show_edit_this_page.py b/doc/sphinxext/show_edit_this_page.py new file mode 100644 index 0000000000000..3b1642018d714 --- /dev/null +++ b/doc/sphinxext/show_edit_this_page.py @@ -0,0 +1,15 @@ +"""Sphinx extension for checking if Edit this Page button should show on this page.""" + +def html_page_context(app, pagename, templatename, context, doctree): + if ( + any(part in context['exclude_edit_this_page_directory'] for part in pagename.split("/")) or + pagename in context['exclude_edit_this_page_pagename'] + ): + context['show_edit_this_page'] = False + else: + context['show_edit_this_page'] = True + + +def setup(app): + app.connect('html-page-context', html_page_context) + return {"parallel_read_safe": True} \ No newline at end of file From a03f795c066e0a064afd53c42ee5345655dde8d8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 1 Aug 2025 04:29:23 +0000 Subject: [PATCH 5/5] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/sphinxext/show_edit_this_page.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/doc/sphinxext/show_edit_this_page.py b/doc/sphinxext/show_edit_this_page.py index 3b1642018d714..5d1df06ab8ff7 100644 --- a/doc/sphinxext/show_edit_this_page.py +++ b/doc/sphinxext/show_edit_this_page.py @@ -1,15 +1,19 @@ """Sphinx extension for checking if Edit this Page button should show on this page.""" + def html_page_context(app, pagename, templatename, context, doctree): if ( - any(part in context['exclude_edit_this_page_directory'] for part in pagename.split("/")) or - pagename in context['exclude_edit_this_page_pagename'] + any( + part in context["exclude_edit_this_page_directory"] + for part in pagename.split("/") + ) + or pagename in context["exclude_edit_this_page_pagename"] ): - context['show_edit_this_page'] = False + context["show_edit_this_page"] = False else: - context['show_edit_this_page'] = True - - + context["show_edit_this_page"] = True + + def setup(app): - app.connect('html-page-context', html_page_context) - return {"parallel_read_safe": True} \ No newline at end of file + app.connect("html-page-context", html_page_context) + return {"parallel_read_safe": True}