From ba387405a46e267b4add6ff1b7e779727d632849 Mon Sep 17 00:00:00 2001 From: ChongChong He Date: Wed, 29 May 2024 03:14:54 +1000 Subject: [PATCH] Add "copy" button to the sphinx documentation page. (#609) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### Description Following https://sphinx-copybutton.readthedocs.io/en/latest/ to add a little “copy” button to the right of the code blocks. Added `sphinx_copybutton` extension in conf.py. Tested in local build (`make html`) and it works fine, but I'm not sure if the `sphinx_copybutton` extension is available on the server where the website HTML is built. ### Checklist _Before this pull request can be reviewed, all of these tasks should be completed. Denote completed tasks with an `x` inside the square brackets `[ ]` in the Markdown source below:_ - [x] I have added a description (see above). - [x] I have added a link to any related issues see (see above). - [x] I have read the [Contributing Guide](https://github.com/quokka-astro/quokka/blob/development/CONTRIBUTING.md). - [ ] I have added tests for any new physics that this PR adds to the code. - [x] I have tested this PR on my local computer and all tests pass. - [ ] I have manually triggered the GPU tests with the magic comment `/azp run`. - [x] I have requested a reviewer for this PR. --------- Co-authored-by: Ben Wibking --- .github/workflows/docs.yml | 2 +- build_docs.sh | 2 +- docs/conf.py | 2 +- docs/requirements.txt | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index a0e5fe3f3..9fe4b98c8 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -34,7 +34,7 @@ jobs: run: | .github/workflows/dependencies/documentation.sh python3 -m pip install --upgrade pip - python3 -m pip install sphinx==5.3.0 sphinx_rtd_theme sphinxcontrib_bibtex + python3 -m pip install sphinx==5.3.0 sphinx_rtd_theme sphinxcontrib_bibtex sphinx-copybutton - name: Install and Build run: | diff --git a/build_docs.sh b/build_docs.sh index e62197fde..b416655ad 100755 --- a/build_docs.sh +++ b/build_docs.sh @@ -12,5 +12,5 @@ cd docs echo "Build the Sphinx documentation for Quokka." #make PYTHON="python3" LATEXMKOPTS="-interaction=nonstopmode" latexpdf -make PYTHON="python3" html &> make_source_html.out +make PYTHON="python3" html cd ../ diff --git a/docs/conf.py b/docs/conf.py index b4887b57a..78df9bb87 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -37,7 +37,7 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [ "sphinxcontrib.bibtex" ] +extensions = [ "sphinxcontrib.bibtex", "sphinx_copybutton" ] bibtex_bibfiles = ["references.bib"] #bibtex_default_style = "plain" diff --git a/docs/requirements.txt b/docs/requirements.txt index 6616495f2..3dacebd09 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,3 +1,5 @@ -breathe==4.31 -sphinx==4.2.0 -sphinxcontrib_bibtex==2.4.1 +sphinx==5.3.0 +sphinxcontrib_bibtex==2.6.2 +sphinx-copybutton==0.5.2 +breathe==4.35.0 +sphinx_rtd_theme==2.0.0