| 1 |
#!/usr/bin/env python |
| 2 |
# SPDX-License-Identifier: MPL-2.0 |
| 3 |
# -*- coding: utf-8 -*- |
| 4 |
# pylint: disable=invalid-name |
| 5 |
|
| 6 |
import datetime |
| 7 |
import os |
| 8 |
import pathlib |
| 9 |
import sys |
| 10 |
import urllib |
| 11 |
|
| 12 |
sys.path.insert(0, os.path.abspath('..')) |
| 13 |
from cryptodatahub.__setup__ import ( # noqa: E402, pylint: disable=wrong-import-position |
| 14 |
__author__, |
| 15 |
__description__, |
| 16 |
__title__, |
| 17 |
__version__, |
| 18 |
) |
| 19 |
|
| 20 |
|
| 21 |
extensions = [ |
| 22 |
'myst_parser', |
| 23 |
'sphinx_sitemap', |
| 24 |
] |
| 25 |
templates_path = ['_templates'] |
| 26 |
source_suffix = '.rst' |
| 27 |
master_doc = 'index' |
| 28 |
|
| 29 |
project = __title__ |
| 30 |
copyright = f'{datetime.datetime.now().year}, {__author__}' # pylint: disable=redefined-builtin |
| 31 |
|
| 32 |
if 'READTHEDOCS' in os.environ: |
| 33 |
version = release = os.environ['READTHEDOCS_VERSION'] |
| 34 |
|
| 35 |
html_baseurl = os.environ['READTHEDOCS_CANONICAL_URL'] |
| 36 |
|
| 37 |
_baseurl_parsed = urllib.parse.urlparse(html_baseurl) |
| 38 |
_baseurl = urllib.parse.ParseResult(_baseurl_parsed.scheme, _baseurl_parsed.netloc, '/', '', '', '').geturl() |
| 39 |
|
| 40 |
sitemap_url_scheme = "{link}" |
| 41 |
|
| 42 |
_robots_txt_lines = [ |
| 43 |
'User-agent: *', |
| 44 |
'', |
| 45 |
'Disallow: # Allow everything', |
| 46 |
'', |
| 47 |
] |
| 48 |
for lang in ('en',): |
| 49 |
for tag in ('latest', 'stable'): |
| 50 |
_robots_txt_lines.append(f'Sitemap: {_baseurl}{lang}/{tag}/sitemap.xml') |
| 51 |
|
| 52 |
_html_extra_dir_name = 'readthedocs' |
| 53 |
_html_extra_path = pathlib.Path(_html_extra_dir_name) |
| 54 |
_html_extra_path.mkdir(exist_ok=True) |
| 55 |
with open(_html_extra_path / 'robots.txt', 'w+', encoding='ascii') as _robots_txt_file: |
| 56 |
_robots_txt_file.write(os.linesep.join(_robots_txt_lines)) |
| 57 |
|
| 58 |
html_extra_path = [ |
| 59 |
_html_extra_dir_name |
| 60 |
] |
| 61 |
else: |
| 62 |
version = release = __version__ |
| 63 |
|
| 64 |
exclude_patterns = ['_build'] |
| 65 |
|
| 66 |
html_title = __title__ + ' — ' + __description__ |
| 67 |
html_theme = 'alabaster' |
| 68 |
html_sidebars = { |
| 69 |
'**': [ |
| 70 |
'about.html', |
| 71 |
'navigation.html', |
| 72 |
'relations.html', |
| 73 |
'searchbox.html', |
| 74 |
'donate.html', |
| 75 |
] |
| 76 |
} |
| 77 |
html_theme_options = { |
| 78 |
'description': __description__, |
| 79 |
'fixed_sidebar': True, |
| 80 |
} |