|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +"""Sphinx configuration overlay for building docs from a release tag. |
| 19 | +
|
| 20 | +Loads ``conf.py`` from a``docs/source`` directory located at |
| 21 | +``DATAFUSION_DOCS_SOURCE`` and overrides the following settings: |
| 22 | +- the version string (``DATAFUSION_DOCS_VERSION``), |
| 23 | +- the site base URL used for the sitemap |
| 24 | +- the version switcher. |
| 25 | +
|
| 26 | +Why? |
| 27 | +
|
| 28 | +Documentation from older release tags do not have the version picker code and |
| 29 | +expect their base URL to be ``/`` rather than ```versions/<version>/``, so we can |
| 30 | +not publish docs built for the archived version without modification. |
| 31 | +
|
| 32 | +Rather than modifying the documentation in the old release branch, |
| 33 | +the release process builds docs with the following command from a main |
| 34 | +checkout: |
| 35 | +
|
| 36 | +sphinx-build -c docs/scripts/release |
| 37 | +""" |
| 38 | + |
| 39 | +import os |
| 40 | +from pathlib import Path |
| 41 | +import sys |
| 42 | + |
| 43 | +source = Path(os.environ["DATAFUSION_DOCS_SOURCE"]).resolve() |
| 44 | +sys.path.insert(0, str(source.parent)) |
| 45 | +exec(compile((source / "conf.py").read_bytes(), str(source / "conf.py"), "exec")) |
| 46 | + |
| 47 | +# Resolve paths relative to the tag, not this configuration overlay. |
| 48 | +templates_path = [str(source / path) for path in templates_path] |
| 49 | +html_static_path = [str(source / path) for path in html_static_path] |
| 50 | +html_extra_path = [str(source / path) for path in html_extra_path] |
| 51 | +html_logo = str(source / html_logo) |
| 52 | +html_favicon = str(source / html_favicon) |
| 53 | + |
| 54 | +version = release = os.environ["DATAFUSION_DOCS_VERSION"] |
| 55 | +html_baseurl = f"https://datafusion.apache.org/versions/{version}/" |
| 56 | +sitemap_url_scheme = "{link}" |
| 57 | +if "sphinx_sitemap" not in extensions: |
| 58 | + extensions.append("sphinx_sitemap") |
| 59 | +html_context = {**html_context, "github_repo": "datafusion", "github_version": version} |
| 60 | +html_theme_options = { |
| 61 | + **html_theme_options, |
| 62 | + "navbar_end": ["version-switcher", "theme-switcher"], |
| 63 | + "check_switcher": False, |
| 64 | + "switcher": { |
| 65 | + "json_url": "/_static/versions.json", |
| 66 | + "version_match": version, |
| 67 | + }, |
| 68 | +} |
| 69 | +# The old tag's absolute redirect would leave the release documentation. |
| 70 | +redirects = {**redirects, "library-user-guide/upgrading": "upgrading/index.html"} |
0 commit comments