From 4014ff1b875aba9fa5ea6e119ff657a463ab9fce Mon Sep 17 00:00:00 2001 From: MOHITKOURAV01 Date: Wed, 19 Nov 2025 13:18:11 +0530 Subject: [PATCH] Document copy button setup and add tests --- CHANGES.rst | 2 ++ docs/contributing.rst | 3 +++ tests/test_docs_copybutton.py | 17 +++++++++++++++++ 3 files changed, 22 insertions(+) create mode 100644 tests/test_docs_copybutton.py diff --git a/CHANGES.rst b/CHANGES.rst index efd076e9..52bb4466 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,8 @@ Unreleased deprecation period. :issue:`5815` - ``template_filter``, ``template_test``, and ``template_global`` decorators can be used without parentheses. :issue:`5729` +- Documentation builds now include copy-to-clipboard buttons for code blocks + via ``sphinx-copybutton``. :issue:`0` Version 3.1.2 diff --git a/docs/contributing.rst b/docs/contributing.rst index dcf24df0..a64fa425 100644 --- a/docs/contributing.rst +++ b/docs/contributing.rst @@ -13,6 +13,9 @@ Copy-to-Clipboard Buttons The Flask docs are built with Sphinx. Follow the steps below to add a copy button to every code block by using the ``sphinx-copybutton`` extension. +.. versionchanged:: 3.2 + Added copy button setup instructions for the documentation build. + 1. Install the extension in your activated virtual environment: .. code-block:: console diff --git a/tests/test_docs_copybutton.py b/tests/test_docs_copybutton.py new file mode 100644 index 00000000..47fc822e --- /dev/null +++ b/tests/test_docs_copybutton.py @@ -0,0 +1,17 @@ +from pathlib import Path + + +def test_docs_dependency_includes_copybutton() -> None: + """Docs dependency group must install sphinx-copybutton.""" + + text = Path("pyproject.toml").read_text(encoding="utf-8") + assert "sphinx-copybutton" in text + + +def test_docs_conf_enables_copybutton() -> None: + """Sphinx config must enable the extension and prompt stripping.""" + + conf = Path("docs/conf.py").read_text(encoding="utf-8") + assert '"sphinx_copybutton"' in conf + assert "copybutton_prompt_text" in conf +