Iris: DOC: easier copy-and-paste of code examples

Created on 9 Jun 2018  路  8Comments  路  Source: SciTools/iris

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.

  • [x] PR for http->https in doc template
  • [x] PR for http->https in released docs
Minor Bug Documentation

All 8 comments

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 ?

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

Thanks for doing this!

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?

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

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?

@tkknight Awesome, job done, thanks! :+1:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lbdreyer picture lbdreyer  路  3Comments

cpelley picture cpelley  路  3Comments

rcomer picture rcomer  路  3Comments

BenMGeo picture BenMGeo  路  4Comments

pp-mo picture pp-mo  路  5Comments