sphinx-hoverxref icon indicating copy to clipboard operation
sphinx-hoverxref copied to clipboard

`:term:` tooltip problems with terms that share definitions

Open zhenry9 opened this issue 5 years ago • 2 comments

As others have said, thanks for the extension! It has made a huge difference in the usefulness of my documentation.

I have the following problem:

I have a glossary page with lots of entries like this:

.. glossary::
  
   term 1
   term 2
      definition for both term 1 and term 2

I have hoverxref setup to show tooltips for terms, However, :term:`Term 1` brings up a tooltip that just says "term 2" and doesn't include the definition. Is there a way around this?

Thanks again!

zhenry9 avatar Dec 21 '20 03:12 zhenry9

Hi @zhenry9! This is probably an error in the backend API and how it's doing the parsing of the content before returning it. Unfortunately, that code is not (yet) public available.

There is no current workaround, sorry, but we will consider it in the following month once we start working more deeply on making that code better and finally public :tada:!

humitos avatar Dec 21 '20 11:12 humitos

I did some experiments on this and it gets dirty too quickly (but, hey!, it works). Basically, we need to:

  • get the specific HTML node for the definition
  • go up on its siblings until we find a different node than dt and save all these dt nodes
  • go down on its siblings until we find a different node than dt and save all these dt nodes
  • remove all nodes that are not: the current node, the next node and none of the saved nodes

Note that this can be implemented in this chunk of code https://github.com/readthedocs/readthedocs.org/pull/8521/files#diff-93aac61b8b6d747d415ef7412a0f6aa10410dd7b1aa229ea075026177915724fR191

humitos avatar Sep 27 '21 12:09 humitos

Any updates? We also hit this bug.

jpfeuffer avatar Feb 02 '23 12:02 jpfeuffer

@jpfeuffer hi! I haven't had the time to work on this issue yet. Would you like to research a little more and open a PR with a proposed fix? In a previous comment I explained my findings and good to potentially solve it.

humitos avatar Feb 03 '23 06:02 humitos

Hi! Question about the code. Why do you (at all) go through the whole glossary and delete everything but the entry you want, instead of creating copies for a new html object with just the node that was found by ID and its next dd node?

jpfeuffer avatar Feb 03 '23 09:02 jpfeuffer

Honestly, I don't think there is a strong reason for that. I suppose either way will generate the same output

humitos avatar Feb 03 '23 09:02 humitos

Ok can you point me to the tests of this part of the API?

jpfeuffer avatar Feb 03 '23 09:02 jpfeuffer

Got it https://github.com/readthedocs/readthedocs.org/blob/main/readthedocs/embed/v3/tests/test_external_pages.py#L216

jpfeuffer avatar Feb 03 '23 10:02 jpfeuffer

Is there an easier way to do a development environment for this? I don't want to install all the docker compose stuff. I just want to do simple python mock tests for the API.

jpfeuffer avatar Feb 03 '23 11:02 jpfeuffer

@jpfeuffer unfortunately, that's not possible. You will need to follow this guide https://docs.readthedocs.io/en/latest/development/install.html to be able to develop the EmbedAPI

humitos avatar Feb 03 '23 11:02 humitos

Ok, sorry then I can't. I do not have 10 GB of free space.

jpfeuffer avatar Feb 03 '23 12:02 jpfeuffer

If you want, I can abuse your CI. Otherwise I am afraid someone else has to finish this.

jpfeuffer avatar Feb 03 '23 12:02 jpfeuffer