Skip to content

Commit ed542fd

Browse files
authored
Merge pull request readthedocs#39 from readthedocs/humitos/micromodal
Support for MicroModal
2 parents 9fb3c66 + 5603ca5 commit ed542fd

19 files changed

+742
-115
lines changed

MANIFEST.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
prune common
22
include LICENSE
3+
34
include hoverxref/_static/js/hoverxref.js_t
5+
46
include hoverxref/_static/js/tooltipster.bundle.min.js
57
include hoverxref/_static/css/tooltipster.bundle.min.css
68
include hoverxref/_static/css/tooltipster-sideTip-shadow.min.css
@@ -9,3 +11,8 @@ include hoverxref/_static/css/tooltipster-sideTip-light.min.css
911
include hoverxref/_static/css/tooltipster-sideTip-borderless.min.css
1012
include hoverxref/_static/css/tooltipster-sideTip-noir.min.css
1113
include hoverxref/_static/css/tooltipster-sideTip-punk.min.css
14+
15+
include hoverxref/_static/js/micromodal.min.js
16+
include hoverxref/_static/css/micromodal.css
17+
include hoverxref/_static/css/sphinx_material.css
18+
include hoverxref/_static/css/sphinx_rtd_theme.css

docs/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ SPHINXBUILD = sphinx-build
77
SOURCEDIR = .
88
BUILDDIR = _build
99

10+
# sphinx-hoverxref expected variables
11+
export READTHEDOCS=True
12+
export READTHEDOCS_PROJECT=sphinx-hoverxref
13+
export READTHEDOCS_VERSION=latest
14+
1015
# Put it first so that "make" without argument is like "make help".
1116
help:
1217
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
@@ -16,4 +21,7 @@ help:
1621
# Catch-all target: route all unknown targets to Sphinx using the new
1722
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
1823
%: Makefile
19-
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
24+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
25+
26+
livehtml:
27+
sphinx-autobuild -E -b html --ignore "autoapi/*" --ignore "*#*" --watch "../hoverxref" $(SPHINXOPTS) $(SOURCEDIR) $(BUILDDIR)/html

docs/_static/css/custom.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.topic-title {
2+
font-size: 150%;
3+
font-family: "Roboto Slab","ff-tisa-web-pro","Georgia",Arial,sans-serif;
4+
}

docs/conf.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,28 @@
5151

5252
# Used when building the documentation from the terminal and using a local Read
5353
# the Docs instance as backend
54-
hoverxref_tooltip_api_host = 'http://localhost:8000'
54+
hoverxref_api_host = 'http://localhost:8000'
5555

5656
if os.environ.get('READTHEDOCS') == 'True':
5757
# Building on Read the Docs
58-
hoverxref_tooltip_api_host = 'https://readthedocs.org'
58+
hoverxref_api_host = 'https://readthedocs.org'
5959
if os.environ.get('LOCAL_READTHEDOCS') == 'True':
6060
# Building on a local Read the Docs instance
61-
hoverxref_tooltip_api_host = 'http://community.dev.readthedocs.io'
61+
hoverxref_api_host = 'http://community.dev.readthedocs.io'
6262

6363
hoverxref_tooltip_maxwidth = 650
6464
hoverxref_auto_ref = True
6565
hoverxref_roles = [
6666
'confval',
6767
]
68+
69+
hoverxref_default_types = {
70+
'hoverxref': 'tooltip',
71+
'ref': 'modal',
72+
'confval': 'tooltip',
73+
'mod': 'modal',
74+
'class': 'modal',
75+
}
6876
hoverxref_domains = [
6977
'py',
7078
]
@@ -222,3 +230,5 @@ def setup(app):
222230
'confval', # rolename
223231
'pair: %s; configuration value', # indextemplate
224232
)
233+
234+
app.add_css_file('css/custom.css')

docs/configuration.rst

Lines changed: 157 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,52 @@ Configuration
22
=============
33

44
The default settings should be enough for most of the cases.
5-
For more specific use cases, you can customize these configuration options in your ``conf.py`` file:
5+
For more specific use cases, you can customize these configuration options in your ``conf.py`` file.
66

7-
.. confval:: hoverxref_project
7+
.. contents:: Table of contents
8+
:local:
9+
:backlinks: none
10+
:depth: 1
811

9-
Description: Read the Docs project slug
12+
General settings
13+
----------------
1014

11-
Default: It defaults to ``READTHEDOCS_PROJECT`` environment variable
15+
These settings are global and have effect on both, tooltips and modal dialogues.
1216

13-
Type: string
17+
.. confval:: hoverxref_default_types
1418

15-
.. confval:: hoverxref_version
19+
Description: Style to use by default when for the embedded content when using ``:hoverxref:`` role.
20+
It also affect the style of and ``:ref:``
1621

17-
Description: Read the Docs version slug
22+
Default: ``{}``
1823

19-
Default: It defaults to ``READTHEDOCS_VERSION`` environment variable
24+
Example:
2025

21-
Type: string
26+
.. code-block:: python
2227
23-
.. confval:: hoverxref_tooltip_api_host
28+
{
29+
'hoverxref': 'modal',
30+
'ref': 'modal', # for hoverxref_auto_ref config
31+
'confval': 'tooltip', # for custom object
32+
'mod': 'tooltip', # for Python Sphinx Domain
33+
'class': 'tooltip', # for Python Sphinx Domain
34+
}
2435
25-
Description: Host URL for the API to retrieve the tooltip content
36+
Type: dictionary
2637

27-
Default: ``https://readthedocs.org``
38+
.. confval:: hoverxref_default_type
39+
40+
Description: Default style when the specific one was not found in :confval:`hoverxref_default_types`.
41+
42+
Default: ``tooltip``
43+
44+
Options: ``tooltip`` or ``modal``
2845

2946
Type: string
3047

3148
.. confval:: hoverxref_auto_ref
3249

33-
Description: Make all ``:ref:`` role to show a tooltip
50+
Description: Make all ``:ref:`` role to show a tooltip.
3451

3552
Default: ``False``
3653

@@ -56,14 +73,6 @@ For more specific use cases, you can customize these configuration options in yo
5673

5774
Type: list
5875

59-
.. confval:: hoverxref_tooltip_class
60-
61-
Description: CSS class to add to ``div`` created for the tooltip
62-
63-
Default: ``rst-content``
64-
65-
Type: string
66-
6776
.. confval:: hoverxref_sphinxtabs
6877

6978
Description: trigger an extra step to render tooltips where its content has a `Sphinx Tabs`_
@@ -84,9 +93,49 @@ For more specific use cases, you can customize these configuration options in yo
8493

8594
.. _Mathjax: http://www.sphinx-doc.org/es/master/usage/extensions/math.html#module-sphinx.ext.mathjax
8695

96+
.. confval:: hoverxref_api_host
97+
98+
Description: Host URL for the API to retrieve the content of the floating window
99+
100+
Default: ``https://readthedocs.org``
101+
102+
Type: string
103+
104+
.. confval:: hoverxref_project
105+
106+
Description: Read the Docs project slug
107+
108+
Default: It defaults to ``READTHEDOCS_PROJECT`` environment variable
109+
110+
Type: string
111+
112+
.. confval:: hoverxref_version
113+
114+
Description: Read the Docs version slug
115+
116+
Default: It defaults to ``READTHEDOCS_VERSION`` environment variable
117+
118+
Type: string
119+
120+
121+
Tooltipster
122+
-----------
123+
124+
These settings have effect only in tooltips.
125+
126+
.. confval:: hoverxref_tooltip_class
127+
128+
Description: CSS class to add to ``div`` created for the tooltip
129+
130+
Default: ``rst-content``
131+
132+
Type: string
133+
134+
87135
.. warning::
88136

89-
The following settings are passed directly to Tooltipster_. See https://iamceege.github.io/tooltipster/#options for more information about their descriptions.
137+
The following settings are passed directly to Tooltipster_.
138+
See https://iamceege.github.io/tooltipster/#options for more information about their descriptions.
90139

91140
.. confval:: hoverxref_tooltip_theme
92141

@@ -131,3 +180,89 @@ For more specific use cases, you can customize these configuration options in yo
131180
Type: string
132181

133182
.. _Tooltipster: https://iamceege.github.io/tooltipster/
183+
184+
185+
MicroModal.js
186+
-------------
187+
188+
These settings have effect only in modal dialogues.
189+
190+
.. confval:: hoverxref_modal_hover_delay
191+
192+
Description: Delay time (in milliseconds) before showing the modal when hover over a ref
193+
194+
Default: ``350``
195+
196+
Type: int
197+
198+
.. confval:: hoverxref_modal_default_title
199+
200+
Description: Title shown when the content does not have one
201+
202+
Default: ``Note``
203+
204+
Type: string
205+
206+
.. confval:: hoverxref_modal_prefix_title
207+
208+
Description: Prefix included in the title of the modal
209+
210+
Default: 📝 (ends with a trailing space)
211+
212+
Type: string
213+
214+
.. confval:: hoverxref_modal_class
215+
216+
Description:
217+
218+
Default: ``rst-content``
219+
220+
Type: string
221+
222+
223+
.. warning::
224+
225+
The following settings are passed directly to `MicroModal.js`_.
226+
See https://micromodal.now.sh/#configuration for more information about their descriptions.
227+
228+
.. confval:: hoverxref_modal_onshow_function
229+
230+
Default: ``None``
231+
232+
Type: string
233+
234+
.. confval:: hoverxref_modal_openclass
235+
236+
Default: ``is-open``
237+
238+
Type: string
239+
240+
.. confval:: hoverxref_modal_disable_focus
241+
242+
Default: ``True``
243+
244+
Type: bool
245+
246+
.. confval:: hoverxref_modal_disable_scroll
247+
248+
Default: ``False``
249+
250+
Type: bool
251+
252+
.. confval:: hoverxref_modal_awaitopenanimation
253+
254+
Default: ``False``
255+
256+
Type: bool
257+
258+
.. confval:: hoverxref_modal_awaitcloseanimation
259+
260+
Default: ``False``
261+
262+
Type: bool
263+
264+
.. confval:: hoverxref_modal_debugmode
265+
266+
Default: ``False``
267+
268+
Type: bool

docs/development.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ To setup this approach, you need to put these settings in the ``conf.py`` of you
2323
2424
hoverxref_project = 'sphinx-hoverxref'
2525
hoverxref_version = 'latest'
26-
hoverxref_tooltip_api_host = 'https://readthedocs.org'
26+
hoverxref_api_host = 'https://readthedocs.org'
2727
2828
After building the documentation all the requests will be done to URLs like::
2929

@@ -84,7 +84,7 @@ To make the extension to work, you will need to define this setting in your ``co
8484

8585
.. code-block:: python
8686
87-
hoverxref_tooltip_api_host = 'http://dev.readthedocs.io:8000'
87+
hoverxref_api_host = 'http://dev.readthedocs.io:8000'
8888
8989
.. tip::
9090

0 commit comments

Comments
 (0)