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

Add floating window tooltips for cross-references in the docs #3083

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"nbsphinx",
"IPython.sphinxext.ipython_console_highlighting",
"sphinx_gallery.load_style",
"hoverxref.extension",
]

# -- sphinxcontrib-bibtex configuration --------------------------------------
Expand Down Expand Up @@ -301,6 +302,31 @@

"""

# -- Options for sphinx-hoverxref --------------------------------------------

# Hoverxref settings

hoverxref_default_type = "tooltip"
hoverxref_auto_ref = True

hoverxref_roles = ["class", "meth", "func", "ref", "term"]
hoverxref_role_types = dict.fromkeys(hoverxref_roles, "tooltip")

hoverxref_domains = ["py"]

# Currently, only projects that are hosted on readthedocs + CPython, NumPy, and
# SymPy are supported
hoverxref_intersphinx = list(intersphinx_mapping.keys())

# Tooltips settings
hoverxref_tooltip_lazy = False
hoverxref_tooltip_maxwidth = 750
hoverxref_tooltip_animation = "fade"
hoverxref_tooltip_animation_duration = 1
hoverxref_tooltip_content = "Loading information..."
hoverxref_tooltip_theme = ["tooltipster-shadow", "tooltipster-shadow-custom"]


# -- Jinja templating --------------------------------------------------------
# Credit to: https://ericholscher.com/blog/2016/jul/25/integrating-jinja-rst-sphinx/

Expand Down
1 change: 1 addition & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ ipython
ipykernel
ipywidgets
sphinx-gallery
sphinx-hoverxref
23 changes: 23 additions & 0 deletions docs/source/_static/pybamm.css
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,26 @@ html[data-theme="dark"] h1 {
html[data-theme="dark"] h3 {
color: #0a6774;
}

/* Overrides for sphinx-hoverxref since it does not support a native dark theme, see */
/* https://github.com/readthedocs/sphinx-hoverxref/issues/231 */

/* These will ensure that the tooltip inherits the PyData colours */

.tooltipster-sidetip.tooltipster-shadow .tooltipster-box {
background: var(--pst-color-background) !important;
}

.tooltipster-sidetip.tooltipster-shadow .tooltipster-arrow {
background: none !important;
overflow: hidden;
position: absolute;
}

.tooltipster-sidetip.tooltipster-shadow.tooltipster-right .tooltipster-arrow-border {
border-right-color: var(--pst-color-background) !important;
}

.tooltipster-sidetip.tooltipster-shadow.tooltipster-left .tooltipster-arrow-border {
border-left-color: var(--pst-color-background) !important;
}
2 changes: 1 addition & 1 deletion docs/source/user_guide/index.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(user)=
(user_guide)=

# PyBaMM user guide

Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ def compile_KLU():
"ipykernel",
"ipywidgets",
"sphinx-gallery",
"sphinx-hoverxref",
], # For doc generation
"dev": [
"pre-commit", # For code style checking
Expand Down
Loading