Skip to content

Add sphinx copybutton extension#865

Merged
MetRonnie merged 2 commits intocylc:masterfrom
wxtim:add.sphix-copybutton
Aug 29, 2025
Merged

Add sphinx copybutton extension#865
MetRonnie merged 2 commits intocylc:masterfrom
wxtim:add.sphix-copybutton

Conversation

@wxtim
Copy link
Member

@wxtim wxtim commented Aug 27, 2025

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.

Add a copy button to code snippets.

image

I've wanted to do this for ages, but last time I looked this extension didn't exist.

Built at https://████████████████/doc/cylc/8.5.2.dev/html/tutorial/scheduling/graphing.html#example

@oliver-sanders
Copy link
Member

(please test this out with diff code-blocks)

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well apart from diff blocks:

Image

What ends up copied:

 [scheduler]
    allow implicit tasks = True
 [scheduling]
    cycling mode = integer
    initial cycle point = 1
    [[graph]]
-        R1 = """
        P1 = """
            buy_ingredients => make_dough
            pre_heat_oven & make_dough => bake_bread
            bake_bread => sell_bread & clean_oven
        """

However I'm not sure if there is a good need to copy diff blocks.

Also, it might be tricky to solve as there is something funky going on with diff blocks when you try to select the text:

image

@oliver-sanders
Copy link
Member

Also, it might be tricky to solve as there is something funky going on with diff blocks:

Diff blocks have some CSS rules to make it easier for users to copy paste:

https://cylc.github.io/cylc-sphinx-extensions/extensions/cylc.sphinx_ext.diff_selection.html

However, this is CSS only, just display, nothing is different about these blocks otherwise.

Suggest turning the copy feature off for diff blocks to avoid user pain in training sessions? Or finding a way to hack it?

@wxtim wxtim force-pushed the add.sphix-copybutton branch from 4490dac to 46a4276 Compare August 28, 2025 09:17
@MetRonnie
Copy link
Member

(Test failures will be fixed by #866)

@MetRonnie MetRonnie merged commit bac47a2 into cylc:master Aug 29, 2025
1 check failed
@wxtim wxtim deleted the add.sphix-copybutton branch September 1, 2025 08:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants