Within Jupyter, there's two options to export notebooks to other formats, using nbconvert either on the command-line or as a library. Both require you to pass the original notebook as input (either as a file name or JSON data).
What I would like to do is essentially automatic, self-contained report generation, i.e. use the nbconvert library within a notebook, to export that same notebook to HTML/PDF on execution. I envisage the export code in the final cell of the document, with instructions to ignore that last cell on export.
My problem is in getting the data. Within the notebook I can access the code cells through In[1]
, Out[2]
etc, but AFAIK there is no such functionality for markdown cells. There's also no (official) method to grab the name of the notebook (no __file__
attribute) to pass information that way.
There's plenty of examples to grab all the cell data from other notebooks - but is there a way to access all the cell data from the current notebook?