Closed willsimmons1465 closed 3 years ago
Hm, unfortunately the fix is not as simple, check out the resulting docs: https://86-73843754-gh.circle-artifacts.com/0/html/index.html
The problem is that in order for the styles to be correctly applied, everything should be enclosed in a jupyter cell container.
So in addition to that, we need to make a JupyterCell
directive, which would create a marked JupyterCellNode
that has its execution skipped. Optimally, we'd also need to attach the input part of that node in the correct place of the notebook, but only after execution, so that the code isn't run. This, however is optional.
Additionally I suggest to rename the docs section to something like "Advanced usage: manually forming Jupyter cells"
@akhmerov Found it easier to just start from master again. Got the formatting mostly there, but can't get the provided inputs and outputs to appear in the same JupyterCellNode
. If that's what you are talking about, then I think I might have to design it with nested directives, e.g. having jupyter-input
and jupyter-output
within a jupyter-cell
directive
Sorry, took me a while to come back to this.
I have looked at the implementation and all looks good except for two related aspects:
jupyter-output
directive without an immediately preceding jupyter-input
, let's catch this case and raise an extension error.
- Probably related: the outputs and inputs seem to be contained within different jupyter cell containers, which results in a different rendering (a gap between the input and the output). Let's instead detect when they are neighbors in the doctree and combine them into a single one. Let me know if you would benefit from advice on the implementation.
I have added an extra pre-processing transform to combine the JupyterCellNode
s from input and outputs when adjacent. The formatting looks much more consistent now which is nice
Yes, this is great!
Looking at the tests I see that we assume that output without input is an error, and don't assume that input without output is an error. This is appropriate, however let's make it official and add a test that only jupyter-input
does work and produces a cell without output.
After that I think all good to go!
Because a CellOutputBundleNode
is always added to each jupyter cell (see this line), we will still have an output cell when only jupyter-input
is given, but we can check that it is empty and hidden
Awesome, thanks for your work @willsimmons1465!
Proposed solution for issue #140
Adds an extra optiondont-run
to cells which means they are not submitted for execution, just simply rendered as a cell.Current drawback of this solution is that the cell is not included in the .ipynb or .py output files.Adds two new directives,jupyter-input
andjupyter-output
which build aCellInputNode
orCellOutputNode
directly. These are added to the .ipynb and .py output files when built. Comments and suggestions welcome.