From 29ca74d5b60b31d0d1d48ff4da5ada3298399b0b Mon Sep 17 00:00:00 2001 From: Quentin Pradet Date: Wed, 6 Sep 2023 23:06:17 +0400 Subject: [PATCH] Fix Read the Docs build (#1668) --- .readthedocs.yaml | 16 ++++++++++++++++ docs/conf.py | 12 ++++-------- noxfile.py | 4 ++-- setup.py | 5 +++-- 4 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 .readthedocs.yaml diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 000000000..2302702f3 --- /dev/null +++ b/.readthedocs.yaml @@ -0,0 +1,16 @@ +version: 2 + +build: + os: ubuntu-22.04 + tools: + python: "3" + +python: + install: + - method: pip + path: . + extra_requirements: + - develop + +sphinx: + fail_on_warning: true diff --git a/docs/conf.py b/docs/conf.py index c3513936f..c770dd805 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -28,7 +28,8 @@ # serve to show the default. import datetime -import os + +import sphinx_rtd_theme import elasticsearch_dsl @@ -116,13 +117,8 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -on_rtd = os.environ.get("READTHEDOCS", None) == "True" - -if not on_rtd: # only import and set the theme if we're building docs locally - import sphinx_rtd_theme - - html_theme = "sphinx_rtd_theme" - html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] +html_theme = "sphinx_rtd_theme" +html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the diff --git a/noxfile.py b/noxfile.py index 8017b39bc..5a5880522 100644 --- a/noxfile.py +++ b/noxfile.py @@ -73,6 +73,6 @@ def lint(session): @nox.session() def docs(session): - session.install(".[develop]", "sphinx-rtd-theme") + session.install(".[develop]") - session.run("sphinx-build", "docs/", "docs/_build", "-b", "html") + session.run("sphinx-build", "docs/", "docs/_build", "-b", "html", "-W") diff --git a/setup.py b/setup.py index 9dc52a2e0..517ad5546 100644 --- a/setup.py +++ b/setup.py @@ -38,8 +38,9 @@ "pytest-mock", "pytz", "coverage", - "sphinx", - "sphinx_rtd_theme", + # Override Read the Docs default (sphinx<2 and sphinx-rtd-theme<0.5) + "sphinx>2", + "sphinx-rtd-theme>0.5", ] setup(