-
Notifications
You must be signed in to change notification settings - Fork 91
Many small fixes to ipython_directive.rst
.
#18
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
Conversation
Including: - Typo fixes (e.g. "Sphinc" -> "Sphinx", "ruin" -> "run", etc.) - Python 3 errors with `print` used as a keyword vs. function - Changing line numbers to start at 1 locally within an `ipython` directive block (because they get renumbered anyhow) - Normalizing all usage of IPython and Sphinx (some places were lowercased, e.g. "ipython" and "sphinx") - Converting tabs to spaces (tabs seemed inadvertent) - Removing comments that have no effect on the block (output is only checked by `doctest` and only displayed during `verbatim`) - "Standardizing" the number of empty lines between sections - Adding whitespace between operators / commas (per PEP8) - Using implicit string concat rather than \-continuation - Using codefont (via double backticks) for pseudo-decorator sections - Adding "Enabling IPython Directive" section which explains which Sphinx extensions enable this behavior
Worth noting: I found this document by reading the |
ipython_directive.rst
Outdated
for this document (see :ref:`ipython_literal`) because otherwise | ||
you will see only the rendered output and not the code that | ||
generated it. Excepting the example above, we will not in general | ||
be showing the liuteral rest in this document that generates the | ||
be showing the literal ReST in this document that generates the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be reST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL! (Just checked https://en.wikipedia.org/wiki/ReStructuredText for "official" abbreviations.) Will update.
inserted, and prompts will be renumbered. So the prompt below should | ||
be renumbered in the rendered docs, and pick up where the block above | ||
left off. | ||
|
||
.. ipython:: | ||
|
||
In [138]: z = x*3 # x is recalled from previous block | ||
In [1]: z = x * 3 # x is recalled from previous block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is numbering restarting from 1 unlike the others?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my description
Changing line numbers to start at 1 locally within an
ipython
directive block (because they get renumbered anyhow)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, but this seems to only have affected here and below, not the ones above. But I see now that that's just an example and not really the 136-th input line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is only one block above (and one verbatim / <code>
section so readers can see the block) and IIUC it's meant to support the opening text of this document:
The IPython directive is a stateful IPython shell for embedding in
Sphinx documents. It knows about standard IPython prompts, and
extracts the input and output lines. These prompts will be renumbered
starting at1
.
I'm happy to change it if you'd like, but ISTM that was the original author's intent.
File "<ipython console>", line 1 | ||
q = z[) # this is a syntax error -- we trap ipy exceptions | ||
^ | ||
SyntaxError: invalid syntax |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the traceback not captured any more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is captured, but this text was never rendered. I am happy to put the built HTML in a gist?
This was part of
Removing comments that have no effect on the block (output is only checked by
doctest
and only displayed duringverbatim
)
ipython_directive.rst
Outdated
@@ -168,40 +139,39 @@ the inputs:: | |||
.. ipython:: | |||
:suppress: | |||
|
|||
In [144]: from pylab import * | |||
In [1]: from pylab import * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pylab
is dead; we should definitely remove this from any examples. Something more reasonable might be import numpy as np; import matplotlib.pyplot as plt
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
w00t! Happy to do that
- Updating "ReST" acronym / initialism to "reST" - Dropping mention of `pylab` for "modern" `matplotlib`
Thanks @tacaswell. I don't have merge privileges, not sure if you do. |
PS Thanks for remembering @tacaswell 😀 |
Thanks for the merge! |
Including:
print
used as a keyword vs. functionipython
directive block (because they get renumbered anyhow)doctest
and only displayed duringverbatim
)