Skip to content

Commit f96139e

Browse files
committed
Full docs for modal dialogues combined with tooltips
1 parent 329b39e commit f96139e

File tree

8 files changed

+72
-17
lines changed

8 files changed

+72
-17
lines changed

docs/_images/modal-example.png

44.4 KB
Loading

docs/_images/tooltip-example.png

45.7 KB
Loading

docs/_static/css/custom.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
img.example {
2+
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
3+
display: block;
4+
margin-left: auto;
5+
margin-right: auto;
6+
}
7+
8+
.topic-title {
9+
font-size: 150%;
10+
font-family: "Roboto Slab","ff-tisa-web-pro","Georgia",Arial,sans-serif;
11+
}

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,5 @@ def setup(app):
224224
'confval', # rolename
225225
'pair: %s; configuration value', # indextemplate
226226
)
227+
228+
app.add_css_file('css/custom.css')

docs/configuration.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@ Configuration
44
The default settings should be enough for most of the cases.
55
For more specific use cases, you can customize these configuration options in your ``conf.py`` file.
66

7+
.. contents:: Table of contents
8+
:local:
9+
:backlinks: none
10+
:depth: 1
711

812
General settings
913
----------------
1014

15+
These settings are global and have effect on both, tooltips and modal dialogues.
16+
1117
.. confval:: hoverxref_type
1218

1319
Description: How to display the embedded content. As a Tooltip or as a Modal dialogue
@@ -86,6 +92,8 @@ General settings
8692
Tooltipster
8793
-----------
8894

95+
These settings have effect only in tooltips.
96+
8997
.. confval:: hoverxref_tooltip_api_host
9098

9199
Description: Host URL for the API to retrieve the tooltip content
@@ -156,6 +164,8 @@ Tooltipster
156164
MicroModal.js
157165
-------------
158166

167+
These settings have effect only in modal dialogues.
168+
159169
.. confval:: hoverxref_modal_hover_delay
160170

161171
Description: Delay time (in milliseconds) before showing the modal when hover over a ref

docs/index.rst

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,69 @@
11
Welcome to sphinx-hoverxref!
22
============================
33

4-
``sphinx-hoverxref`` is a Sphinx_ extension to add tooltips on the cross references of the documentation embedding the content of the linked section.
4+
``sphinx-hoverxref`` is a Sphinx_ extension to show a floating window (tooltips or modal dialogues) on the cross references of the documentation embedding the content of the linked section on them. With ``sphinx-hoverxref``, you don't need to click a link to see what's in there.
55

6-
Online documentation:
7-
https://sphinx-hoverxref.readthedocs.io/
6+
We currently support two different types of floating windows: Tooltip_ and Modal_.
87

9-
Source code repository (and issue tracker):
10-
https://github.com/readthedocs/sphinx-hoverxref/
118

12-
Badges:
13-
|Build| |PyPI version| |Docs badge| |License|
9+
Tooltip
10+
-------
11+
12+
By defining :confval:`hoverxref_type <hoverxref_type>` as ``'tooltip'`` (default) you will get a tooltip when hover references.
13+
14+
.. figure:: _images/tooltip-example.png
15+
:width: 75%
16+
:class: example
17+
18+
19+
Modal
20+
-----
21+
22+
By defining :confval:`hoverxref_type <hoverxref_type>` as ``'modal'`` you will get a modal when hover references.
23+
24+
.. image:: _images/modal-example.png
25+
:width: 75%
26+
:class: example
1427

1528

1629
Usage
1730
-----
1831

19-
To show a tooltip on a reference, use the role ``hoverxref`` to link to any document or section.
32+
To show a floating window on a reference, use the role ``hoverxref`` to link to any document or section.
2033

21-
Writing this reStructuredText:
34+
Writing this reStructuredText in your document:
2235

2336
.. code-block:: rst
2437
25-
This will :hoverxref:`show a tooltip <hoverxref:hoverxref>` in the linked words.
38+
This will :hoverxref:`show a floating window <hoverxref:hoverxref>` in the linked words.
2639
27-
will render to:
40+
it will be rendered to:
2841

29-
This will :hoverxref:`show a tooltip <hoverxref:hoverxref>` in the linked words.
42+
This will :hoverxref:`show a floating window <hoverxref:hoverxref>` in the linked words.
3043

3144
.. tip::
3245

3346
This new ``hoverxref`` role is an alias of the ``ref`` role and works in the same.
34-
See :ref:`usage:usage` for more detailed information about and other examples.
47+
See :ref:`usage:usage` for more detailed information about this and other examples.
3548

3649

3750
----
3851

52+
Reference
53+
---------
54+
55+
56+
Online documentation:
57+
https://sphinx-hoverxref.readthedocs.io/
58+
59+
Source code repository (and issue tracker):
60+
https://github.com/readthedocs/sphinx-hoverxref/
61+
62+
Badges:
63+
|Build| |PyPI version| |Docs badge| |License|
64+
65+
66+
3967
.. toctree::
4068
:maxdepth: 2
4169
:caption: Contents

docs/installation.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To do this, add this extension to your Sphinx's extensions in the ``conf.py`` fi
3232
3333
3434
After installing the package and adding the extension in the ``conf.py`` file,
35-
you can use ``:hoverxref:`` role to show a tooltip when hovering with the mouse.
35+
you can use ``:hoverxref:`` role to show a tooltip [#]_ when hovering with the mouse.
3636

3737
.. warning::
3838

@@ -47,3 +47,5 @@ See :ref:`usage:usage` for more use cases and :ref:`configuration:configuration`
4747

4848

4949
.. _Read the Docs: https://readthedocs.org/
50+
51+
.. [#] we use tooltips as a generic word, but we refer to both, tooltips and modal dialogues

docs/usage.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Usage
22
=====
33

44
This extension defines a custom role called ``:hoverxref:``.
5-
When this role is used, it will show a tooltip when the ``hover`` mouse event is triggered,
5+
When this role is used, it will show a tooltip [#]_ when the ``hover`` mouse event is triggered,
66
and will embed the content of the document/section the link is pointing to, into the tooltip's content.
77

88
``:hoverxref:`` role uses Sphinx's internals reference resolution to find out where the link points to.
@@ -15,11 +15,11 @@ Simplest usage example,
1515

1616
.. code-block:: rst
1717
18-
This will :hoverxref:`show a tooltip <hoverxref:section>` in the linked words to ``hoverxref``.
18+
This will :hoverxref:`show a tooltip <hoverxref:hoverxref>` in the linked words to ``hoverxref``.
1919
2020
will render to this:
2121

22-
This will :hoverxref:`show a tooltip <hoverxref:section>` in the linked words to ``hoverxref``.
22+
This will :hoverxref:`show a tooltip <hoverxref:hoverxref>` in the linked words to ``hoverxref``.
2323

2424

2525
Tooltip on custom object
@@ -122,3 +122,5 @@ Show a :hoverxref:`tooltip with Mathjax <mathjax:Mathjax>` formulas.
122122

123123
.. _sphinx-tabs: https://github.com/djungelorm/sphinx-tabs
124124
.. _mathjax: http://www.sphinx-doc.org/es/master/usage/extensions/math.html#module-sphinx.ext.mathjax
125+
126+
.. [#] we use tooltips as a generic word, but we refer to both, tooltips and modal dialogues

0 commit comments

Comments
 (0)