Skip to content

DOC: easier copy-and-paste of code examples #3057

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

Closed
2 tasks done
tv3141 opened this issue Jun 8, 2018 · 8 comments
Closed
2 tasks done

DOC: easier copy-and-paste of code examples #3057

tv3141 opened this issue Jun 8, 2018 · 8 comments

Comments

@tv3141
Copy link
Contributor

tv3141 commented Jun 8, 2018

Code blocks in the user guide and reference guide cannot be copied and pasted as a whole as they contain >>> and ...:

>>> for foo in bar:
...     print(foo)

One approach would be a toggle like numpy uses in their manual.

@pelson
Copy link
Member

pelson commented Jun 11, 2018

We actually used to have this. Looks like it stopped working.

Looks like the move over to https stopped this working (diagnosed by enabling insecure scripts in the docs).

The line is at https://github.com/SciTools/iris/blob/master/docs/iris/src/_templates/layout.html#L9. It would take a PR to scitools/iris and a PR to http://github.com/scitools/scitools.org.uk to search and replace http://docs.python.org/2/_static/copybutton.js with https://docs.python.org/2/_static/copybutton.js. Interested in doing it @tv3141 ?

@tv3141
Copy link
Contributor Author

tv3141 commented Jun 12, 2018

@pelson Yes, I can have a look at this.

@pelson
Copy link
Member

pelson commented Jun 20, 2018

Thanks for doing this!

@pelson pelson closed this as completed Jun 20, 2018
@tv3141
Copy link
Contributor Author

tv3141 commented Nov 9, 2018

Copybutton is broken in Iris2.2, example

I think I broke this in #3071.

Iris2.2 code blocks:

<div class="highlight-default notranslate">
<div class="highlight">
<pre>
<span></span>
...

Iris2.1 code blocks:

<div class="highlight-python notranslate" style="position: relative;">
<div class="highlight">
<span class="copybutton" title="Hide the prompts and output" style="cursor: pointer; position: absolute; top: 0px; right: 0px; border-color: rgb(204, 204, 204); border-style: solid; border-width: 0.994318px; color: rgb(204, 204, 204); font-family: monospace; padding-left: 0.2em; padding-right: 0.2em;">&gt;&gt;&gt;</span>
<pre>
...

@pelson Do you want to reopen this ticket or open a new one?

@pelson pelson reopened this Dec 3, 2018
@pelson
Copy link
Member

pelson commented Dec 3, 2018

I've reopened. Are you interested in taking a look at this @tv3141?

@bjlittle bjlittle modified the milestones: v2.1.1, v2.3.0 Jun 9, 2019
@stephenworsley stephenworsley self-assigned this Aug 23, 2019
@stephenworsley
Copy link
Contributor

This may be worth looking at scipy/scipy-sphinx-theme#6.

@bjlittle bjlittle modified the milestones: v2.3.0, v3.1.0 Nov 13, 2019
@tkknight
Copy link
Contributor

I believe the new Read The Docs style documentation has resolved this issue. The sphinx_copybutton extension is used to handle this.

See https://scitools-iris.readthedocs.io/en/latest/installing.html for an example (note the icon on the right of the commands)

Note this documentation url is the latest, this points to master. When there is a release for Iris there will also be a stable release and a tagged release too.

I think we can close this issue now?

@bjlittle
Copy link
Member

@tkknight Awesome, job done, thanks! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants