* [PATCH] Add the sphinx-copybutton extension
@ 2025-12-18 9:44 Antonin Godard
2025-12-18 15:50 ` Quentin Schulz
0 siblings, 1 reply; 3+ messages in thread
From: Antonin Godard @ 2025-12-18 9:44 UTC (permalink / raw)
To: docs; +Cc: Thomas Petazzoni, Quentin Schulz, Antonin Godard
This extension adds a copy button to code-blocks.
It was added to the buildtools tarballs for documentation with
commit ebf14a6dc1a5 ("python3-sphinx-copybutton: add recipe") in
OE-Core, so the the Autobuilder can use it.
Add it as a requirement in the docs, including in Ubuntu requirements.
According to https://pkgs.org/download/python3-sphinx-copybutton this
packages is provided under "python3-sphinx-copybutton" on all the
versions of Ubuntu we support.
Suggested-by: Quentin Schulz <quentin.schulz@cherry.de>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
documentation/Pipfile | 1 +
documentation/conf.py | 1 +
documentation/tools/host_packages_scripts/pip3_docs.sh | 2 +-
documentation/tools/host_packages_scripts/ubuntu_docs.sh | 2 +-
4 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/documentation/Pipfile b/documentation/Pipfile
index 7ee1d22905..1fa2df31e7 100644
--- a/documentation/Pipfile
+++ b/documentation/Pipfile
@@ -9,6 +9,7 @@ verify_ssl = true
sphinx = "*"
sphinx-rtd-theme = "*"
pyyaml = "*"
+sphinx-copybutton = "*"
[requires]
python_version = "3"
diff --git a/documentation/conf.py b/documentation/conf.py
index c07b6c4199..860962e0dc 100644
--- a/documentation/conf.py
+++ b/documentation/conf.py
@@ -66,6 +66,7 @@ extensions = [
'sphinx.ext.autosectionlabel',
'sphinx.ext.extlinks',
'sphinx.ext.intersphinx',
+ 'sphinx_copybutton',
'yocto-vars'
]
autosectionlabel_prefix_document = True
diff --git a/documentation/tools/host_packages_scripts/pip3_docs.sh b/documentation/tools/host_packages_scripts/pip3_docs.sh
index fd6ad98053..907ecec55c 100644
--- a/documentation/tools/host_packages_scripts/pip3_docs.sh
+++ b/documentation/tools/host_packages_scripts/pip3_docs.sh
@@ -1 +1 @@
-sudo pip3 install sphinx sphinx_rtd_theme pyyaml
+sudo pip3 install sphinx sphinx_rtd_theme pyyaml sphinx-copybutton
diff --git a/documentation/tools/host_packages_scripts/ubuntu_docs.sh b/documentation/tools/host_packages_scripts/ubuntu_docs.sh
index 67bb810946..c322b61e42 100644
--- a/documentation/tools/host_packages_scripts/ubuntu_docs.sh
+++ b/documentation/tools/host_packages_scripts/ubuntu_docs.sh
@@ -1 +1 @@
-sudo apt install git librsvg2-bin locales make python3-saneyaml python3-sphinx-rtd-theme sphinx
+sudo apt install git librsvg2-bin locales make python3-saneyaml python3-sphinx-rtd-theme python3-sphinx-copybutton sphinx
---
base-commit: d84d916d4fc505e8386693306b6a90b0064c0518
change-id: 20251217-sphinx-copybutton-40e213333b4a
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] Add the sphinx-copybutton extension
2025-12-18 9:44 [PATCH] Add the sphinx-copybutton extension Antonin Godard
@ 2025-12-18 15:50 ` Quentin Schulz
2025-12-19 9:21 ` [docs] " Antonin Godard
0 siblings, 1 reply; 3+ messages in thread
From: Quentin Schulz @ 2025-12-18 15:50 UTC (permalink / raw)
To: Antonin Godard, docs; +Cc: Thomas Petazzoni
Hi Antonin,
On 12/18/25 10:44 AM, Antonin Godard wrote:
> This extension adds a copy button to code-blocks.
>
> It was added to the buildtools tarballs for documentation with
> commit ebf14a6dc1a5 ("python3-sphinx-copybutton: add recipe") in
> OE-Core, so the the Autobuilder can use it.
>
> Add it as a requirement in the docs, including in Ubuntu requirements.
> According to https://pkgs.org/download/python3-sphinx-copybutton this
> packages is provided under "python3-sphinx-copybutton" on all the
> versions of Ubuntu we support.
>
Not enough sadly.
Go to
yocto-docs/documentation/_build/html/ref-manual/terms.html#term-Build-Directory
and click the copy button. It'll copy the $ as well, and it shouldn't.
First, I believe those code blocks should be console and not shell (or
shell but we remove $ in front). Note that some file have their
highlight language changed to shell, c.f. the toaster files, so a simple
grep will not return everything that needs to be changed.
Second, we may need to configure copybutton, e.g.
https://sphinx-copybutton.readthedocs.io/en/latest/use.html#strip-and-configure-input-prompts-for-code-cells
at the very least I guess.
FYI on Fedora, I believe we should be able to use packages from the
package feed for all docs since f41 (but since we say we still support
f39 and f40, not applicable right now).
Cheers,
Quentin
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [docs] [PATCH] Add the sphinx-copybutton extension
2025-12-18 15:50 ` Quentin Schulz
@ 2025-12-19 9:21 ` Antonin Godard
0 siblings, 0 replies; 3+ messages in thread
From: Antonin Godard @ 2025-12-19 9:21 UTC (permalink / raw)
To: quentin.schulz, docs; +Cc: Thomas Petazzoni
Hi,
On Thu Dec 18, 2025 at 4:50 PM CET, Quentin Schulz via lists.yoctoproject.org wrote:
[...]
> Second, we may need to configure copybutton, e.g.
> https://sphinx-copybutton.readthedocs.io/en/latest/use.html#strip-and-configure-input-prompts-for-code-cells
> at the very least I guess.
Good point, I'll add "$ " as the copybutton_prompt_text, so the dollar sign
isn't copied. That way code-blocks containing it will be stripped off when
copying, and others that do not contain it can still be copied as-is.
There's certainly improvements to be made to convert all existing shell code-blocks
but I think this is already an improvement as-is.
Thanks,
Antonin
--
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-12-19 9:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 9:44 [PATCH] Add the sphinx-copybutton extension Antonin Godard
2025-12-18 15:50 ` Quentin Schulz
2025-12-19 9:21 ` [docs] " Antonin Godard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox