Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion docs/src/main/sphinx/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,16 @@ def setup(app):

needs_sphinx = '3.0'

extensions = ['myst_parser', 'backquote', 'download', 'issue', 'sphinx_copybutton']
extensions = [
'myst_parser',
'backquote',
'download',
'issue',
'sphinx_copybutton',
'redirects',
]

redirects_file = 'redirects.txt'

templates_path = ['templates']

Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/sphinx/connector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ from different data sources.
Prometheus <connector/prometheus>
Redis <connector/redis>
Redshift <connector/redshift>
SingleStore <connector/memsql>
SingleStore <connector/singlestore>
SQL Server <connector/sqlserver>
System <connector/system>
Thrift <connector/thrift>
Expand Down
94 changes: 94 additions & 0 deletions docs/src/main/sphinx/ext/redirects.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

# Copyright (c) 2017 Stephen Finucane.
# Version 0.1.0 modified April 10, 2023 for Trino use.
# See https://github.com/sphinx-contrib/redirects/pull/6

import os

from sphinx.builders import html as html_builder
from sphinx.builders import dirhtml as dirhtml_builder
from sphinx.util import logging

logger = logging.getLogger(__name__)

TEMPLATE = """<html>
<head><meta http-equiv="refresh" content="0; url=%s"/></head>
</html>
"""


def generate_redirects(app):

path = os.path.join(app.srcdir, app.config.redirects_file)
if not os.path.exists(path):
logger.info("Could not find redirects file at '%s'", path)
return

if isinstance(app.config.source_suffix, dict):
in_suffixes = list(app.config.source_suffix)
else:
in_suffixes = app.config.source_suffix

if not isinstance(app.builder, html_builder.StandaloneHTMLBuilder):
logger.warn(
"The 'sphinxcontib-redirects' plugin is only supported "
"for the 'html' and 'dirhtml' builder, but you are using '%s'. "
"Skipping...", type(app.builder)
)
return

from_suffix = to_suffix = '.html'
if type(app.builder) == dirhtml_builder.DirectoryHTMLBuilder:
from_suffix = '/index.html'
to_suffix = '/'

with open(path) as redirects:
for line in redirects.readlines():
from_path, to_path = line.rstrip().split(' ')

logger.debug("Redirecting '%s' to '%s'", from_path, to_path)

for in_suffix in in_suffixes:
if from_path.endswith(in_suffix):
from_path = from_path.replace(in_suffix, from_suffix)
to_path_prefix = (
'..%s'
% os.path.sep
* (len(from_path.split(os.path.sep)) - 1)
)
to_path = to_path_prefix + to_path.replace(
in_suffix, to_suffix
)

if not to_path:
raise Exception('failed to find input file!')

redirected_filename = os.path.join(app.builder.outdir, from_path)
redirected_directory = os.path.dirname(redirected_filename)
if not os.path.exists(redirected_directory):
os.makedirs(redirected_directory)

with open(redirected_filename, 'w') as f:
f.write(TEMPLATE % to_path)


def setup(app):
app.add_config_value('redirects_file', 'redirects', 'env')
app.connect('builder-inited', generate_redirects)
return {
'parallel_read_safe': True,
'parallel_write_safe': True,
}
1 change: 1 addition & 0 deletions docs/src/main/sphinx/redirects.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
connector/memsql.rst connector/singlestore.rst
2 changes: 1 addition & 1 deletion docs/src/main/sphinx/release/release-326.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ General
* Fix incorrect query results when query contains ``LEFT JOIN`` over ``UNNEST``. (:issue:`2097`)
* Fix performance regression in queries involving ``JOIN``. (:issue:`2047`)
* Fix accounting of semantic analysis time when queued queries are cancelled. (:issue:`2055`)
* Add :doc:`/connector/memsql`. (:issue:`1906`)
* Add :doc:`/connector/singlestore`. (:issue:`1906`)
* Improve performance of ``INSERT`` and ``CREATE TABLE ... AS`` queries containing redundant
``ORDER BY`` clauses. (:issue:`2044`)
* Improve performance when processing columns of ``map`` type. (:issue:`2015`)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/main/sphinx/release/release-334.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Hive connector
MemSQL connector
----------------

* Include :doc:`/connector/memsql` in the server tarball and RPM. (:issue:`3743`)
* Include :doc:`/connector/singlestore` in the server tarball and RPM. (:issue:`3743`)

MongoDB connector
-----------------
Expand Down