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

Commit f6e533f

Browse files
committed
Default hoverxref_api_host to the proxied API
1 parent 90fdb72 commit f6e533f

File tree

5 files changed

+9
-55
lines changed

5 files changed

+9
-55
lines changed

docs/Makefile

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ SOURCEDIR = .
88
BUILDDIR = _build
99

1010
# sphinx-hoverxref expected variables
11-
export READTHEDOCS=True
1211
export READTHEDOCS_PROJECT=sphinx-hoverxref
1312
export READTHEDOCS_VERSION=latest
1413

docs/conf.py

+2-16
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
@@ -65,22 +63,10 @@
6563
'sphinx': 'tooltip',
6664
}
6765

68-
# Used when building the documentation from the terminal and using a local Read
69-
# the Docs instance as backend
70-
hoverxref_api_host = 'http://localhost:8000'
71-
72-
if os.environ.get('READTHEDOCS') == 'True':
73-
# Building on Read the Docs
66+
# Used when building the documentation locally.
67+
if os.environ.get('READTHEDOCS') != 'True':
7468
hoverxref_api_host = 'https://readthedocs.org'
7569

76-
if os.environ.get('PROXIED_API_ENDPOINT') == 'True':
77-
# Use the proxied API endpoint
78-
hoverxref_api_host = '/_'
79-
80-
if os.environ.get('LOCAL_READTHEDOCS') == 'True':
81-
# Building on a local Read the Docs instance
82-
hoverxref_api_host = 'http://community.dev.readthedocs.io'
83-
8470
hoverxref_tooltip_maxwidth = 650
8571
hoverxref_auto_ref = True
8672
hoverxref_roles = [

docs/configuration.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,9 @@ These settings are global and have effect on both, tooltips and modal dialogues.
160160

161161
.. confval:: hoverxref_api_host
162162

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

165-
Default: ``https://readthedocs.org``
165+
Default: ``/_``
166166

167167
Type: string
168168

docs/development.rst

+3-34
Original file line numberDiff line numberDiff line change
@@ -56,45 +56,14 @@ Serve the documentation locally with this command:
5656

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

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

8062
You can `install Read the Docs locally following these instructions`_.
81-
Although, it may be too complicated just to retrieve the same content that you could have in https://readthedocs.org.
82-
83-
To make the extension to work, you will need to define this setting in your ``conf.py`` file:
84-
85-
.. code-block:: python
86-
87-
hoverxref_api_host = 'http://dev.readthedocs.io:8000'
88-
89-
.. tip::
90-
91-
The value of this setting should be the same as ``PUBLIC_API_URL``.
92-
93-
Once you have done that, you can just import the project directly in your local instance,
94-
and the tooltips should work without problem.
95-
96-
.. _install Read the Docs locally following these instructions: https://docs.readthedocs.io/en/stable/development/install.html
63+
You don't need to change anything to be able to use your local instance,
64+
the default :confval:`hoverxref_api_host` value should work.
9765

66+
.. _install Read the Docs locally following these instructions: https://docs.readthedocs.io/page/development/install.html
9867

9968
Permanent tooltip to work with CSS
10069
----------------------------------

hoverxref/extension.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -367,11 +367,11 @@ def setup(app):
367367
app.add_config_value('hoverxref_default_type', 'tooltip', 'env')
368368
app.add_config_value('hoverxref_intersphinx', [], 'env')
369369
app.add_config_value('hoverxref_intersphinx_types', {}, 'env')
370-
app.add_config_value('hoverxref_api_host', 'https://readthedocs.org', 'env')
370+
app.add_config_value('hoverxref_api_host', '/_', 'env')
371371

372372
# Tooltipster settings
373373
# Deprecated in favor of ``hoverxref_api_host``
374-
app.add_config_value('hoverxref_tooltip_api_host', 'https://readthedocs.org', 'env')
374+
app.add_config_value('hoverxref_tooltip_api_host', '/_', 'env')
375375
app.add_config_value('hoverxref_tooltip_theme', ['tooltipster-shadow', 'tooltipster-shadow-custom'], 'env')
376376
app.add_config_value('hoverxref_tooltip_interactive', True, 'env')
377377
app.add_config_value('hoverxref_tooltip_maxwidth', 450, 'env')

0 commit comments

Comments
 (0)