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

Tooltip on sidebar #52

Open
humitos opened this issue Apr 9, 2020 · 1 comment
Open

Tooltip on sidebar #52

humitos opened this issue Apr 9, 2020 · 1 comment
Labels
Feature New feature

Comments

@humitos
Copy link
Member

humitos commented Apr 9, 2020

It may be interesting to be able to hover on the sidebar and get the first paragraph of the content referenced.

  • Requires a change in the backend to let it know to return chunked content and not the whole section
  • Would be good to make the amount of content configurable via a hoverxref_ config that is sent to the backend
@humitos humitos added the Feature New feature label Apr 9, 2020
@humitos
Copy link
Member Author

humitos commented Apr 11, 2020

I found the place where the toctree is created is at https://github.com/sphinx-doc/sphinx/blob/b08a00af739ffbf5e957c0649ac4c4c8d4f866ed/sphinx/environment/adapters/toctree.py#L261-L265

Adding this chunk of code into that section inside the for, the sidebar shows tooltips:

                refnode['classes'].extend(['hoverxref', 'tooltip'])
                refnode._hoverxref = {
                    'data-project': 'sphinx-hoverxref',
                    'data-version': 'latest',
                    'data-doc': 'configuration',
                    'data-docpath': '/configuration.html',
                    'data-section': 'configuration',
                }

I wasn't able to find all the data that I need because the target is missing in these nodes (take into account they are not sphinx.addnodes.pending_xref but just regular docutils.nodes.reference nodes.

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

No branches or pull requests

1 participant