Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Remove '>>>' from documentation to allow copy/paste #339

Closed
isedwards opened this Issue · 6 comments

3 participants

@isedwards

Representing the python prompt in documentation causes copy/paste issues for blocks of code.

>>> cube = iris.load_cube(filename)
>>> print cube
air_temperature           (latitude: 73; longitude: 96)

Possible solutions:
1.No distinction (code and output are inline - in a single code block)

cube = iris.load_cube(filename)
print cube
air_temperature           (latitude: 73; longitude: 96)

2.Sequential (two code blocks - with output following the code)

cube = iris.load_cube(filename)
print cube

air_temperature (latitude: 73; longitude: 96)

3.Nested (output in a code block inside the original)

print cube
        ``air_temperature          (latitude: 73; longitude: 96)``

4.Insert '>>>' as an image at the start of necessary lines

@rhattersley
Owner

I've seen interactive widgets that let you show the >>> by default but let you hide them when copying. That lets you have the best of both worlds.

@pelson
Owner

Agreed. See the standard python documentation for a good solution: http://docs.python.org/3/tutorial/errors.html#syntax-errors

Getting this functionality into basic Sphinx would be a great addition that many projects would benefit from.

While we're at it, we should try to get the version pull down that you see at the top of the python docs too - I think that would be a really nice feature for the Iris docs.

@rhattersley
Owner

While we're at it, we should try to get the version pull down ...

Yes - that'd be very :tada: ... but perhaps best kept in a separate PR.

@isedwards

In some places we also use

example script

[source code]

where the 'source code' link is generated in sphinx by...
.. literalinclude:: example.py

@pelson
Owner

I've implemented the a copy button (which removes the >>>) as found on the python docs. @iedwards - I'm not sure what your previous comment meant, could you clarify please?

@pelson
Owner

Solved by the little button in the top right of each code block. :wink:

@pelson pelson closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.