Skip to content
This repository was archived by the owner on Apr 9, 2025. It is now read-only.

Default hoverxref_api_host to the proxied API #134

Merged
merged 5 commits into from
Mar 28, 2023
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
5 changes: 0 additions & 5 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# sphinx-hoverxref expected variables
export READTHEDOCS=True
export READTHEDOCS_PROJECT=sphinx-hoverxref
export READTHEDOCS_VERSION=latest

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Expand Down
10 changes: 2 additions & 8 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
Expand Down Expand Up @@ -75,12 +73,8 @@
'sphinx': 'tooltip',
}

# Used when building the documentation from the terminal and using a local Read
# the Docs instance as backend
hoverxref_api_host = 'http://localhost:8000'

if os.environ.get('READTHEDOCS') == 'True':
# Building on Read the Docs
# Used when building the documentation locally.
if os.environ.get('READTHEDOCS') != 'True':
hoverxref_api_host = 'https://readthedocs.org'

if os.environ.get('PROXIED_API_ENDPOINT') == 'True':
Expand Down
4 changes: 2 additions & 2 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,14 +151,14 @@ These settings are global and have effect on both, tooltips and modal dialogues.

.. confval:: hoverxref_api_host

Description: Host URL for the API to retrieve the content of the floating window
Description: Host or root URL for the API to retrieve the content of the floating window

.. warning::

You shouldn't modify this setting unless you know what you are doing.
Its default should be fine to build the documentation and make it work in Read the Docs.

Default: ``https://readthedocs.org``
Default: ``/_``

Type: string

Expand Down
18 changes: 0 additions & 18 deletions docs/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,6 @@ Serve the documentation locally with this command:

Now, you can hit http://localhost:9000/ and you should see your documentation here.


Avoid CORS on local backend
+++++++++++++++++++++++++++

When building the documentation locally,
the API calls will be blocked by the browser because of :abbr:`CORS (Cross Origin Resource Sharing)`
(you are hitting the URL http://localhost:9000/ and the API calls are to https://readthedocs.org/).

You can disable this while developing our extension.
To do this, you can open Google Chrome with these arguments:

.. prompt:: bash

google-chrome-stable --disable-web-security --user-data-dir='/tmp/testing'

If Firefox, you can install this add-ons: `Allow CORS: Access-Control-Allow-Origin <https://addons.mozilla.org/es/firefox/addon/access-control-allow-origin/>`_.


Using a local Read the Docs instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
4 changes: 2 additions & 2 deletions hoverxref/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,13 +348,13 @@ def setup(app):
app.add_config_value('hoverxref_default_type', 'tooltip', 'env')
app.add_config_value('hoverxref_intersphinx', [], 'env')
app.add_config_value('hoverxref_intersphinx_types', {}, 'env')
app.add_config_value('hoverxref_api_host', 'https://readthedocs.org', 'env')
app.add_config_value('hoverxref_api_host', '/_', 'env')
app.add_config_value('hoverxref_sphinx_version', sphinx.__version__, 'env')
app.add_config_value('hoverxref_tooltip_lazy', False, 'env')

# Tooltipster settings
# Deprecated in favor of ``hoverxref_api_host``
app.add_config_value('hoverxref_tooltip_api_host', 'https://readthedocs.org', 'env')
app.add_config_value('hoverxref_tooltip_api_host', '/_', 'env')
app.add_config_value('hoverxref_tooltip_theme', ['tooltipster-shadow', 'tooltipster-shadow-custom'], 'env')
app.add_config_value('hoverxref_tooltip_interactive', True, 'env')
app.add_config_value('hoverxref_tooltip_maxwidth', 450, 'env')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_htmltag.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def test_js_render(app, status, warning):
"animationDuration: 0",
"contentAsHTML: true",
"content: 'Loading...'",
"var url = 'https://readthedocs.org' + '/api/v3/embed/?' + $.param(params);",
"var url = '/_' + '/api/v3/embed/?' + $.param(params);",
textwrap.indent(
textwrap.dedent("""
var params = {{
Expand Down