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

Hoverxref still not working on Jupyter Book? #180

Closed
mscharling opened this issue May 3, 2022 · 15 comments · Fixed by #205
Closed

Hoverxref still not working on Jupyter Book? #180

mscharling opened this issue May 3, 2022 · 15 comments · Fixed by #205
Assignees
Labels
Needed: design decision A core team decision is required

Comments

@mscharling
Copy link

Hi there,

I'm currently trying to implement sphinx-hoverxref in my Jupyter Book and I can't make it work. I'm aware of the relatively new version of Jupyter Book working with RTD theme and that makes me wonder why it won't work. So, have I missed something or does sphinx-hoverxref not work with Jupyter Book?

@humitos
Copy link
Member

humitos commented May 4, 2022

Hi @mscharling! I'm not a user of Jupyter Book. Can you explain to me why it doesn't work? What error gives you or what's the problem you are having? Thanks!

@humitos humitos added the Needed: more information A reply from issue author is required label May 4, 2022
@mscharling
Copy link
Author

mscharling commented May 4, 2022

Sure, I thought it was unnecessary to put in if it was known to be unsupported. But.. I'm mostly interested in the {term} part of hoverxref:

In my _config.yml I have added:

sphinx:
  ...
  extra_extensions:
    - hoverxref.extension

In my Jupyter Book-folder and in the hoverxref-folder I have created conf.py with

hoverxref_roles = [
    'term',
]

I have a glossary.md with

{glossary} 
example
   and a lot of text to explain the example.

And lastly I then call "[...] {term}´example´ [...]" in my text markdown file.

When I hover "example" nothing shows and I don't get any errors when building my book. It runs normally and I get the usual {term} click-functionality of the linking to the ref in my glossary.md file.

@humitos
Copy link
Member

humitos commented May 5, 2022

In my Jupyter Book-folder and in the hoverxref-folder I have created conf.py with

Shouldn't this config be in the _config.yml when using Jupyter Book? See https://jupyterbook.org/en/latest/advanced/sphinx.html#manual-sphinx-configuration

I don't think you have to use a conf.py when using Jupyter Book.

@mscharling
Copy link
Author

mscharling commented May 5, 2022

Shouldn't this config be in the _config.yml when using Jupyter Book? See https://jupyterbook.org/en/latest/advanced/sphinx.html#manual-sphinx-configuration

Oh, yeah. That is of course a mistake. I have now added

sphinx:
  config:
    ...
    hoverxref_roles: term

in my _config.yml. Now I get the following error when building my book:

"Using default style (tooltip) for unknown typ (term). Define it in hoverxref_role_types."

The book is still builded but removes the "example" from {term}´example´. When I look into domains.py for hoverxref I don't see anything missing. What could it then be?

@mscharling mscharling reopened this May 5, 2022
@mscharling
Copy link
Author

Misclicked.. 😅

@humitos
Copy link
Member

humitos commented May 6, 2022

Now I get the following error when building my book:

"Using default style (tooltip) for unknown typ (term). Define it in hoverxref_role_types."

This is not an error, just an info message. That's fine. If you want to remove that message, you can specify which tooltip type it should be used for term: https://sphinx-hoverxref.readthedocs.io/en/latest/configuration.html#confval-hoverxref_role_types

The book is still builded but removes the "example" from {term}´example´. When I look into domains.py for hoverxref I don't see anything missing. What could it then be?

I'm not sure. This could be a problem on Jupyter Book, maybe? I haven't seen this issue when using Sphinx directly.

Also, can you share the repository to your docs, or a basic example of how I can get the same behavior so I can test it by myself? Another option could be to ask in the Jupyter Book issue tracker itself, since I'm not sure this is a problem on hoverxref itself.

@humitos humitos added the Support Support question label May 6, 2022
@mscharling
Copy link
Author

Also, can you share the repository to your docs, or a basic example of how I can get the same behavior so I can test it by myself? Another option could be to ask in the Jupyter Book issue tracker itself, since I'm not sure this is a problem on hoverxref itself.

Sure. I've created the repository with some example code here. Thank you for taking your time to investigate this.

@humitos
Copy link
Member

humitos commented May 10, 2022

I've created the repository with some example code here.

I'm not sure to follow your example code. There is only one file there README.md. Maybe you forgot to push some changes?

hoverxref_roles: term

Also, this should be a list (see https://sphinx-hoverxref.readthedocs.io/en/latest/configuration.html#confval-hoverxref_roles). So I think you need something like:

sphinx:
  config:
    ...
    hoverxref_roles:
      - term

@mscharling
Copy link
Author

I'm not sure to follow your example code. There is only one file there README.md. Maybe you forgot to push some changes?

The files are in the gh-pages branch. However, I did not recognize that was the builded files. I have uploaded the source files in the main branch now.

sphinx:
  config:
    ...
    hoverxref_roles:
      - term

I actually already did try that. 😢

@humitos humitos self-assigned this May 23, 2022
@humitos humitos moved this to Planned in 📍Roadmap May 23, 2022
@humitos
Copy link
Member

humitos commented May 30, 2022

I found the issue.

Steps to reproduce it:

  1. Create the book and install dependencies
fades -d jupyter-book -d sphinx-hoverxref -d matplotlib -x jupyter-book create mynewbook/
  1. Edit the YAML to setup hoverxref
# _config.yml

sphinx:
  config:
    hoverxref_roles:
      - term
    hoverxref_role_types:
      term: modal
  extra_extensions:
    - hoverxref.extension
  1. Edit mynewbook/intro.md to add:
```{glossary}
Term one
  An indented explanation of term 1
```

Here is my term!

{term}`Term one`

Is it shown here?
  1. Build the book
fades -d jupyter-book -d sphinx-hoverxref -d matplotlib -x jupyter-book build mynewbook/

When you open mynewbook/_build/html/index.html you will see that the Term one is not shown. However, if you inspect the DOM, the HTML element is there. It seems there is a problem with CSS where Jupyter Book's theme interferes with the .tooltip (opacity: 0) and .modal (display: none) classes making them invisible.

Screenshot_2022-05-30_16-22-35

@choldgraf @chrisjsewell do you know where those CSS classes come from?

@humitos humitos added Needed: design decision A core team decision is required and removed Needed: more information A reply from issue author is required Support Support question labels May 30, 2022
@humitos humitos moved this from Planned to In progress in 📍Roadmap May 30, 2022
@choldgraf
Copy link

Hmmm good question, either bootstrap or it's in the theme css itself. I suspect it's the latter because I'm guessing you tested this extension with bootstrap already. Want to open an issue in the book theme?

@humitos
Copy link
Member

humitos commented Jun 23, 2022

Thanks @choldgraf. I opened executablebooks/sphinx-book-theme#577

@mscharling feel free to subscribe there as well, in case you want to follow up the news about this issue.

humitos added a commit that referenced this issue Jun 27, 2022
Avoid collisioning with other CSS frameworks/themes/etc.

See executablebooks/sphinx-book-theme#577
Closes #180
humitos added a commit that referenced this issue Jun 27, 2022
Avoid collisioning with other CSS frameworks/themes/etc.

See executablebooks/sphinx-book-theme#577
Closes #180
humitos added a commit that referenced this issue Jun 28, 2022
Avoid collisioning with other CSS frameworks/themes/etc.

See executablebooks/sphinx-book-theme#577
Closes #180
@humitos
Copy link
Member

humitos commented Jun 28, 2022

Hi @mscharling! Would you like to try installing sphinx-hoverxref from #205 with your project and let me know if it works as you expected?

@humitos humitos moved this from In progress to Needs review in 📍Roadmap Jun 28, 2022
humitos added a commit that referenced this issue Jul 6, 2022
* Prefix all CSS classes with `hxr-`

Avoid collisioning with other CSS frameworks/themes/etc.

See executablebooks/sphinx-book-theme#577
Closes #180

* Update tests to use the prefix `hxr-`

* Refactor code to use CSS prefix variable
Repository owner moved this from Needs review to Done in 📍Roadmap Jul 6, 2022
@humitos
Copy link
Member

humitos commented Jul 7, 2022

Hi @mscharling! I just deployed a new version of this extension: 1.1.2. Please, give it a try and let me know if this makes it work properly on your Jupyter Book project. I hope it does! 👍🏼

@mscharling
Copy link
Author

mscharling commented May 1, 2024

Hi @humitos, sorry for the late respons. Lots of time has gone without working on my project... However, nice to see that this is now possible for Jupyter Books. My project is currently not using RTD and from #278 I guess I will have to wait checking whether this works for my project or not. Thank you for your time on this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: design decision A core team decision is required
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants