Have a complete TOC when editing notebook

nbdev’s doc builder creates doc sections

  • out of every function or class
  • from every call to show_doc

However, when I work in or edit the notebook, only the show_doc entries have a markdown field and are therefore appearing in Jupyterlab’s TOC. It would be really helpful if all the other def/class cells appear as well to quickly maneuver across the notebook.

Does anybody have a solution for this?

Add a Markdown cell and write the following code.

#hide
## header2

This will show:

  • Jupyter Notebook : #hide, header2
  • Jupyter lab toc : header2
  • nbdev generated document : nothing

So you can use “jupyter lab toc header” to fly around your notebook without displaying anything in the document.

1 Like

While this solution works, it’s quite inelegantly looking with all those “hide” entries in the notebook:

image

and this:

Is there really no other way I’m missing?

1 Like

Yes you can do this by following headings with a single dash for example

My Heading -

Will put My Heading on the TOC but it will be hidden when the docs render

cc: @jeremy

2 Likes

Thanks! NOW I see it in the docs under “Removing fake headers”. I just didn’t know what was meant with fake headers, so I glanced over it too fast, maybe if there’d be an example of a doc cell with a fake header, someone also not knowing what to look for could find it better? I can put in a PR…

I didn’t get this to work

#| hide -
## Real title

But trying to make it work I realized about the different behavior in Jupyter Lab TOC when pressing “Toggle Markdown Text cells”

Toggle Markdown Text cells

Note: The video would show the same if I keep the - after the hide

Like @michaelaye, it took me a while to find this info.