diff --git a/docs/Makefile b/docs/Makefile index 8e5394ff..0170576d 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -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) diff --git a/docs/conf.py b/docs/conf.py index 914ae2e7..8294ece9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -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 @@ -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': diff --git a/docs/configuration.rst b/docs/configuration.rst index 79771263..d99c2a59 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -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 diff --git a/docs/development.rst b/docs/development.rst index 4e43ba8c..747613a3 100644 --- a/docs/development.rst +++ b/docs/development.rst @@ -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 `_. - - Using a local Read the Docs instance ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/hoverxref/extension.py b/hoverxref/extension.py index f8f3ce4c..78d22169 100644 --- a/hoverxref/extension.py +++ b/hoverxref/extension.py @@ -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') diff --git a/tests/test_htmltag.py b/tests/test_htmltag.py index ebf38cd1..45c85abc 100644 --- a/tests/test_htmltag.py +++ b/tests/test_htmltag.py @@ -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 = {{