Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks
Tracked by #36
choldgraf opened this issue Aug 24, 2021 · 2 comments · Fixed by #41
Closed
2 tasks
Tracked by #36

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

choldgraf opened this issue Aug 24, 2021 · 2 comments · Fixed by #41
Labels
enhancement New feature or request needs discussion

Comments

@choldgraf
Copy link
Member

choldgraf commented Aug 24, 2021

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
@choldgraf
Copy link
Member Author

cc @akhmerov - do you have any thoughts about how we could most-easily decide whether to load thebe in projects that aren't using the directive here?

@akhmerov
Copy link
Contributor

I have refreshed my memory of how sphinx-thebe works, and indeed understand the problem now, with the selector being invisible as long as we only have the AST.

Would it make sense to change the sphinx-thebe configuration to take a node or a list of nodes instead, and add the class = 'thebe-container' attribute or something like that to those nodes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs discussion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants