sphinx-extensions2 / sphinx-tippy

Get rich tool tips in your sphinx documentation!
https://sphinx-tippy.readthedocs.io
MIT License
33 stars 5 forks source link

How to use in offline environment? #3

Closed prokie closed 1 year ago

prokie commented 1 year ago

Hello!

How can I use this package in an offline environment? I tried downloading tippy.js from https://unpkg.com/tippy.js@0.11.3/dist/tippy.js and put it in _static/js/tippy.js and then my conf.py looks like this

extensions = ["sphinx_tippy"]

templates_path = ["_templates"]
exclude_patterns = []

# -- Options for HTML output -------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = "sphinx_rtd_theme"
html_static_path = ["_static"]

pygments_style = "sphinx"
html_css_files = [
    "css/custom.css",
]
html_js_files = ["js/plotly.js", "js/tippy.js"]
tippy_js = ("js/tippy.js",)

But I get Uncaught ReferenceError: tippy is not defined in firefox console

chrisjsewell commented 1 year ago

Heya, I'm not sure off hand I'm afraid, but you may want to have a look in your browser's developers tools, to have a look at the order things are being loaded. For instance in firefox:

image
chrisjsewell commented 1 year ago

i.e. tippy needs to have been loaded, before _static/tippy/index...js

prokie commented 1 year ago

Yes, and it is. I am using the the tippy.js with popper.js included but I am still getting this warning in the console.

Source map error: Error: NetworkError when attempting to fetch resource.
Resource URL: file:///proj/build/html/_static/js/tippy.js
Source Map URL: popper.js.map
prokie commented 1 year ago

Does it work for you with the following configuration in conf.py?

html_js_files = ["js/tippy.js"]
tippy_js = ("js/tippy.js",)
prokie commented 1 year ago

I got it working now, I will update the issue tomorrow with the solution. One problem, that made debugging a lot tougher was this issue with sphinx https://github.com/sphinx-doc/sphinx/issues/11163. With an empty searchindex.js, no hovers are possible.

prokie commented 1 year ago

To get offline mode working I need to have the following in conf.py

html_js_files = ["js/tippy.js", "js/popper.js"]
tippy_js = ["js/popper.js", "js/tippy.js"]

Where tippy is downloaded from https://unpkg.com/tippy.js@6.3.7/dist/tippy-bundle.umd.min.js and popper is downloaded from https://unpkg.com/@popperjs/core@2.11.6/dist/umd/popper.min.js

pique-b commented 8 months ago

By following the steps above and updating the conf.py got it to work in offline mode. Tested it by clearing the build files and re-compiling.

The .js files were downloaded from sources as suggested here and here) .

However, tooltips for links such as wikipedia and DOI fails to load, even in online mode. Compiling the docs again while connected to the net also does not make them to work. Only when all generated files are removed with make clean and compiling again (while connected to the net) enables them again.