-
Notifications
You must be signed in to change notification settings - Fork 132
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
Use of nbconvert TemplateExporter to exclude input/output and/or the related in/out prompts #131
Comments
You can try to access it with |
This does indeed work and is sufficient to hide the output prompt. So with this we can hide input code, input and output prompts. If ok for you, I'll be happy to create a pull request and an addition to the documentation (e.g. with a notebook 'Options2HideInformation.ipynb' explaining how to use these options) |
I'm not very enthusiastic about hiding stuff, but several people already asked for something like that, so I guess I'll have to accept it if you make a nice PR. |
I understand your remark but it's how you look at it. |
IMHO if you don't want to show the code, Jupyter notebook is the wrong tool for you. There are tons of tools for automated document generation and many different templating languages available for you to choose from, you don't have to use Jupyter. But of course, every tool can be abused, and to a certain degree that's OK. And if those |
first...nbsphinx is an nice tool and great work...!
There are some situations where the source code in the report or presentation is not desired - but for the editing must be present. The fine thing is with nbsphinx I have code for generating charts and normal text together in one document. But for the paper version I do not need every line of the source code. Is there now a way for nbsphinx to 'disappear' the source code but to print the output? |
@rddaz2013 The situation here is unchanged. I still think it's a bad thing, nobody has shown me an example that would change my mind, but I'm still open to accepting a PR nevertheless. Nobody has created such a PR yet. I think in the meantime |
From the point of view of the idea of Jupyter, 'suppressing' the source code is certainly not a good reason to do it. I am completely on your side @mgeier But for the 'Old World' who want a report without calculation and just want to see the graphs on a printable paper - it would be incredibly practical. Practically because I have only one workflow to produce the document with source or without. |
Is there any update on this? Being able to hide code and output prompts is vital for my use case. @rddaz2013 There are plenty of valid use cases for hiding input that do not violate the idea of Jupyter. For example, I may generate tikz schematic figures with ipython-tikz, but I do not want the tikz source code appearing in my output. |
A quick update from my end. I used my simple solution in a project that lasted about 10 months for about 15 fully automated runs. I encountered no issues. I didn't come up with a PR due to my current workload and also a little bit because of the given remarks. I think that the ideal solution would be both options : hiding input all together, only for a certain (set of) pages and tag-based filtering. I was thinking of finding a solution for all these options at once. So I have to dig in the tag-based filtering first (hopefully after may). PS. an example in favor of this possibility: see also what people in the R-world are doing with R-markdown, R-notebooks, R-bookdown,... In addition to that the reticulate package recently gives one the possibility to use Python code in those solutions (not optimal yet imho). In Python you have pweave but it misses the overall functionality of sphinx |
Any progress on this? I agree with @DavidPowell that this would be very useful! |
Tag-based filtering works if |
Sorry for being unclear. I know (and use) the feature of |
Sorry, I was unclear: tag-based filtering should also work in |
I know how to use it invoking |
@mgeier I'd like to challenge your view that this proposal represents a misuse of Jupyter notebooks. Regarding your earlier comment
I am not aware of any tool other than Jupyter that gives us the ability to generate rich output with Python (or any other language), inspect the results directly inline, iteratively improve them with quick feedback, and then store the results in the same document as the input. The only alternative I can think of is a python script with a whole bunch of rich outputs stored as separate files. To me, Jupyter notebooks seem like the ideal tool for authoring html documents with rich content, I can easily include matplotlib/holoviews/bohek plots, tikz schematics, ipython widgets (which can work well in static output as long as they don't need a server backend), latex equations, videos etc. Back to the technical issues, currently the only way for Anyway, the proposed modifications do look more or less ready to go, so if there is a consensus on this approach then I'm willing to go ahead and create a pull request. My only hesitation is that it might be better to allow an nbconvert configuration object to be passed by the user (potentially overriding some of the values set by nbsphinx), allowing the many nbconvert options to be utilised without requiring nbsphinx to support them all. Pros of a user-specified nbconvert configuration:
Cons:
|
Sorry @mapio, I was totally wrong, tag-based filtering does not work in Thanks @DavidPowell for your comment. I agree with most of it. I agree that the Jupyter notebook is a great tool for interactively exploring stuff and sharing this stuff (including rich media) with the world. But as much as I think that hiding is bad, I'm willing to accept a PR for this issue here, as I already mentioned above.
I don't know about consensus, but it looks fine to me.
I'm not generally against that, but I'm also not sure if that's a good idea. Especially I wouldn't count on the options related to I don't have a problem with mirroring some of the
I'm open to any suggestions for refactorings or other improvements! |
@DavidPowell Thanks for the PR. Just for clarification: I'm not planning to remove |
To everyone interested in this issue, on the PR (see #185) I am proposing to only implement hiding code cell input, input prompts and output prompts. If you have a use case which isn't covered by these features, please comment here or in the PR. |
So the "workarounds" discussed here aren't for an out-of-box |
Why not just div.prompt {display: none;}
|
In order to use this for every notebook at once I'm still trying some things out (see #15) for my earlier comments)
As suggested there, I'v added some nbsphinx options and used the global setting in conf.py
which is used then in the config setting of Exporter(nbconvert.RSTExporter)
This works fine but not for every output prompt.
I tried to solve it but apparently in class NbOutput(rst.Directive) I don't seem to be able to get hold of the "exclude_output_prompt" setting.
With a global variable I can tackle this but still trying to figure out how to do it correctly without using this 'dirty hack':
See: changes
Any Idea how I can pass env.config.nbsphinx_exclude_output_prompt to the run method of the class NbOutput?
The text was updated successfully, but these errors were encountered: