Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: copybutton does not copy complete example #9263

Closed
mosc9575 opened this issue Jul 22, 2024 · 1 comment · Fixed by #9264
Closed

DOC: copybutton does not copy complete example #9263

mosc9575 opened this issue Jul 22, 2024 · 1 comment · Fixed by #9264

Comments

@mosc9575
Copy link
Contributor

mosc9575 commented Jul 22, 2024

What happened?

In the documentation sometimes the copy button fails to copy the complete example. One example can be seen in the HDF section

failing_copy_button

This is because the number of dots (4) are not matched by the regular expression of the copy button, this regular expression needs a small tweak.

To explain the problem in more detail, the io page uses ipython to run the example code and there are many cells. The regular expression

copybutton_prompt_text = r">>> |\.\.\. |\$ |In \[\d*\]: | {2,5}\.\.\.: | {5,8}: "

is working working for the first 9 cells. If there is a double digit cell with a multi line example, the copy button does not work.
The regular expression looks for 3 dots ans a double dot. But for larger numbers there are the length of the number of the cell plus two dots.

@keewis
Copy link
Collaborator

keewis commented Jul 22, 2024

interestingly enough, it looks like this has been the behavior of the ipython sphinx extension since 15 years ago, which deviates from what the ipython shell itself does (it left-pads with spaces). At least the sphinx extension makes sure all code cells are consistent, even the verbatim ones.

@keewis keewis added topic-documentation and removed needs triage Issue that has not been reviewed by xarray team member labels Jul 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants