Skip to content

Allow loading logic that doesn't depend on ThebeButtonNode #34

@choldgraf

Description

@choldgraf

Description / Summary

Right now sphinx-thebe will only load if it detects ThebeButtonNode on a page. However, if a theme is using sphinx-thebe to load thebe, but not the ThebeButtonNode, then thebe won't load for them.
We should find some way around this and also determine how common of a use-case this is.

Value / benefit

This is useful for anyone that wants to piggy-back off of this extension but without using the directives provided by this theme. A good examples of this is the Sphinx Book Theme, which manually activates thebe:

https://github.com/executablebooks/sphinx-book-theme/blob/9a2da30342ace86978ddbd345eb69f5b4479b31c/sphinx_book_theme/topbar/launchbuttons.html#L29

and this logic is triggered here:

https://github.com/executablebooks/sphinx-book-theme/blob/e05def5b9a4fc777f702553a0bcaf7939440dbd3/sphinx_book_theme/launch.py#L118

Implementation details

A couple ideas:

  • Check for an in-page metadata like thebe: true
  • Check for an html context variable like context['use_thebe']
  • Check for some other kind of in-page content (e.g. special case the class thebe-launch-button?)
  • Make it configurable to use any other kind of object in the doctree

Tasks to complete

  • Decide what's the best way to support other kinds of nodes/objects for thebe loading
  • Implement

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions