From b3a52f4882fedd3c563cf185b413004ec56e936d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Tue, 17 Oct 2023 22:38:31 -0400 Subject: [PATCH] doc: Configure copybutton extension for ignoring shell prompts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add required settings for telling the copybutton Sphinx extension to ignore prompts when copying a code block. Both bash prompt and Zephyr UART prompt are ignored. Examples of the new behavior: .. code-block:: console $ echo "Hello World" Hello World The copied text will be: 'echo "Hello World"'. .. code-block:: console uart:~$ l2cap connect 29 Chan sec: 1 L2CAP connection pending Channel 0x20000210 connected Channel 0x20000210 status 1 uart:~$ l2cap send 3 14 Rem 2 Rem 1 Rem 0 Outgoing data channel 0x20000210 transmitted Outgoing data channel 0x20000210 transmitted Outgoing data channel 0x20000210 transmitted The copied text will be: 'l2cap connect 29\nl2cap send 3 14'. Signed-off-by: Benjamin Cabé --- doc/conf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/conf.py b/doc/conf.py index 2785ec5438b..388ccd66015 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -313,6 +313,11 @@ graphviz_dot_args = [ "-Ecolor=gray60", ] +# -- Options for sphinx_copybutton ---------------------------------------- + +copybutton_prompt_text = r"\$ |uart:~\$ " +copybutton_prompt_is_regexp = True + # -- Linkcheck options ---------------------------------------------------- extlinks = {