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
ipython_directive, report except/warn in block and add :okexcept: :okwarning: options to suppress #4870
Conversation
…warning: options to suppress
@@ -245,13 +246,15 @@ def block_parser(part, rgxin, rgxout, fmtin, fmtout): | |||
class EmbeddedSphinxShell(object): | |||
"""An embedded IPython instance to run inside Sphinx""" | |||
|
|||
def __init__(self, exec_lines=None): | |||
def __init__(self, exec_lines=None,state=None): |
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.
space after coma. :-)
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.
PEP8 is the bane of my existence.
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.
Pushed. There's a lot of PEP8 stuff here, you want the full storm? I consider it just diff noise.
@@ -421,6 +428,34 @@ def process_input(self, data, input_prompt, lineno): | |||
elif is_semicolon: # get spacing right | |||
ret.append('') | |||
|
|||
# context information | |||
filename = self.state.document.current_source | |||
lineno = self.state.document.current_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.
self.state could be None
I think, this would then not work.
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.
Mixing maybe ... not sure, will re-read. Was confused by kipped lines on github.
Usually we fix pep-8 only on code we touch. |
So , |
Haven't had much experience with sphinx extensions, I admit. I just sort of fell into this |
Fair, enough. |
I'm game, what do you suggest? |
I don't know, what does @takluyver think ? he did review the other PR, so might have better input than me on this one. |
I added a commit to handle that just in case, I'm open to any and all other suggestions. |
This looks OK to me, but I have no special knowledge of Sphinx extensions. I think pandas is the biggest user of |
We've been using :okexcept: for a long time, and it's been fine. It didn't report I think it's solid. If you want to wait a little while we dogfood, no problem. |
I wonder how well this works for other kernels such as IRuby. |
OK, let's give it a couple of days for pandas to spot any major flaws. If you don't let us know of any issues, we'll merge it then. At present, I think this uses a shell object within the process, so it wouldn't work with another kernel. It could be rewritten to use the kernel architecture. |
It's not strictly necessary to pass in
|
Also, it looks like line numbers are not report when raising an exception on a failed doctest. Note to self or anyone who wants to do it: This should probably be added in. |
I had to scan the file several times until I understood where self.directive is coming from... You hid it well. |
We don't use doctests in pandas, she's all yours. |
Eck. Not proud of that one...probably should have passed it to |
fwiw, I felt bad about passing in the state arg. Sometimes you can't win. |
Added some comments re https://github.com/ipython/ipython/pull/4803/files#r9180526 |
(I'm no longer sure where this comment should be. In this PR or in the merged #4803) Got it, but I suppose that means the fix is valid only if the value of |
There might be some confusion here, mine or yours I'm not sure.
The problem is this:
That's my understanding of what I fixed, being 3rd on the scene and having no insight Certainly, I may have misunderstood the problem and fixed it by mistake. Convince me. also, we might actually be talking about |
You may want to look at the original fix in pandas, which I scrapped in favor of fixing |
So To the question of whether or not its a real use case, my guess is that most projects will not use it. But if changing the prompt were so uncommon, then why does IPython allow it in the first place? Support for customized prompts was put in only to be consistent with this feature of IPython. Practically, maybe the thing to do is just leave your fix as is and wait for people with customized prompts to complain. My guess is that the fix would cause problems only for customized prompts that do not have a space after the colon (if there is even a colon). Would a comment in the code making this clear be sufficient? That is, something stating that the spacing test is designed to work with the default output prompt and might cause problems with customized prompts. |
Done. |
My take is that customising your prompt in the shell makes sense, but documentation should be written with the default prompt. |
I've compiled the docs many times over the last few days and unless there are further Heads up, there's another PR coming with unicode/encoding fixes which should be |
Seems ready. Aside: should IPython move the content of http://matplotlib.org/sampledoc/ipython_directive.html to its own documentation? We can expand it and keep it updated then too. |
Thanks guys, merging. |
ipython_directive, report except/warn in block and add :okexcept: :okwarning: options to suppress
ipython_directive, report except/warn in block and add :okexcept: :okwarning: options to suppress
2nd try on #4866, upstreaming ipython_directive enhancements from pandas.
ipython::
block execution to stdout.:okexcept:
and:okwarning:
options to allow the user to supress such output on per-block basis.Exceptions raised in ipython blocks are currently not reported and silently end up in
the rendered output. Similarly for Warnings.
Example output: