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

Commit 0924e62

Browse files
authored
Default hoverxref_api_host to the proxied API (#134)
1 parent 9a45b39 commit 0924e62

File tree

6 files changed

+7
-36
lines changed

6 files changed

+7
-36
lines changed

docs/Makefile

-5
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ 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-
1510
# Put it first so that "make" without argument is like "make help".
1611
help:
1712
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
#
31
# Configuration file for the Sphinx documentation builder.
42
#
53
# This file does only contain a selection of the most common options. For a
@@ -75,12 +73,8 @@
7573
'sphinx': 'tooltip',
7674
}
7775

78-
# Used when building the documentation from the terminal and using a local Read
79-
# the Docs instance as backend
80-
hoverxref_api_host = 'http://localhost:8000'
81-
82-
if os.environ.get('READTHEDOCS') == 'True':
83-
# Building on Read the Docs
76+
# Used when building the documentation locally.
77+
if os.environ.get('READTHEDOCS') != 'True':
8478
hoverxref_api_host = 'https://readthedocs.org'
8579

8680
if os.environ.get('PROXIED_API_ENDPOINT') == 'True':

docs/configuration.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ These settings are global and have effect on both, tooltips and modal dialogues.
151151

152152
.. confval:: hoverxref_api_host
153153

154-
Description: Host URL for the API to retrieve the content of the floating window
154+
Description: Host or root URL for the API to retrieve the content of the floating window
155155

156156
.. warning::
157157

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

161-
Default: ``https://readthedocs.org``
161+
Default: ``/_``
162162

163163
Type: string
164164

docs/development.rst

-18
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,6 @@ Serve the documentation locally with this command:
5454

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

57-
58-
Avoid CORS on local backend
59-
+++++++++++++++++++++++++++
60-
61-
When building the documentation locally,
62-
the API calls will be blocked by the browser because of :abbr:`CORS (Cross Origin Resource Sharing)`
63-
(you are hitting the URL http://localhost:9000/ and the API calls are to https://readthedocs.org/).
64-
65-
You can disable this while developing our extension.
66-
To do this, you can open Google Chrome with these arguments:
67-
68-
.. prompt:: bash
69-
70-
google-chrome-stable --disable-web-security --user-data-dir='/tmp/testing'
71-
72-
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/>`_.
73-
74-
7557
Using a local Read the Docs instance
7658
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7759

hoverxref/extension.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ def setup(app):
348348
app.add_config_value('hoverxref_default_type', 'tooltip', 'env')
349349
app.add_config_value('hoverxref_intersphinx', [], 'env')
350350
app.add_config_value('hoverxref_intersphinx_types', {}, 'env')
351-
app.add_config_value('hoverxref_api_host', 'https://readthedocs.org', 'env')
351+
app.add_config_value('hoverxref_api_host', '/_', 'env')
352352
app.add_config_value('hoverxref_sphinx_version', sphinx.__version__, 'env')
353353
app.add_config_value('hoverxref_tooltip_lazy', False, 'env')
354354

355355
# Tooltipster settings
356356
# Deprecated in favor of ``hoverxref_api_host``
357-
app.add_config_value('hoverxref_tooltip_api_host', 'https://readthedocs.org', 'env')
357+
app.add_config_value('hoverxref_tooltip_api_host', '/_', 'env')
358358
app.add_config_value('hoverxref_tooltip_theme', ['tooltipster-shadow', 'tooltipster-shadow-custom'], 'env')
359359
app.add_config_value('hoverxref_tooltip_interactive', True, 'env')
360360
app.add_config_value('hoverxref_tooltip_maxwidth', 450, 'env')

tests/test_htmltag.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def test_js_render(app, status, warning):
4444
"animationDuration: 0",
4545
"contentAsHTML: true",
4646
"content: 'Loading...'",
47-
"var url = 'https://readthedocs.org' + '/api/v3/embed/?' + $.param(params);",
47+
"var url = '/_' + '/api/v3/embed/?' + $.param(params);",
4848
textwrap.indent(
4949
textwrap.dedent("""
5050
var params = {{

0 commit comments

Comments
 (0)