jupyter-sphinx
jupyter-sphinx copied to clipboard
Consider refactoring how ThebeLab works
As I've been looking through the Jupyter Sphinx code, I am curious what you all think about the role that ThebeLab plays in the codebase. To me, since ThebeLab is a 100% web-based tool, it could be simpler to support if we just used Javascript to activate it. Instead of having special Node types just for Thebelab, we could use regular cell, input, and output nodes. I think this could make the codebase easier to understand and maintain.
I imagine something like this:
- The docutils structure knows nothing about thebelab, it's just CellNode, CellInputNode, and CellOutputNode
- The user-facing Thebelab configuration remains the same
- One additional Thebe configuration is a selector for code blocks that we wish to convert into interactive thebelab blocks
- A directive is used to place the "activate thebelab" button on a page somewhere.
- Or, a little thebelab button is automatically placed next to some code blocks using javascript at load time (perhaps similar to how sphinx-copybutton works https://sphinx-copybutton.readthedocs.io/en/latest/)
- Clicking the button will trigger a JS script that uses the selector mentioned above, adds the appropriate metadata to those code blocks, and then triggers the Thebelab action on them.
I feel like this way there wouldn't need to be all the extra logic of adding node types that are thebelab-specific.
Do folks have thoughts on that?
I fully agree with the proposal.