Files
tryton/naiad/doc/conf.py
T
Cédric Krier 35e4dac5d6 Fix computation of documentation series for odd minor version
(grafted from f4d6cf9d57ce7c69bcde185f933f866c0dd40301)

--HG--
branch : 8.0
2026-04-20 21:23:36 +02:00

80 lines
2.4 KiB
Python

# This file is part of Tryton. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import os
base_url = os.environ.get('DOC_BASE_URL')
if base_url:
modules_url = base_url + '/modules-{module}/'
trytond_url = base_url + '/server/'
else:
modules_url = 'https://docs.tryton.org/{series}/modules-{module}/'
trytond_url = 'https://docs.tryton.org/{series}/server/'
def get_info():
import json
import subprocess
module_dir = os.path.dirname(os.path.dirname(__file__))
info = dict()
metadata_cmd = 'python3 -m build -qq --metadata'
if os.environ.get('DOC_NO_ISOLATION'):
metadata_cmd += ' --no-isolation'
metadata = subprocess.check_output(
metadata_cmd, shell=True, encoding='utf-8', cwd=module_dir).strip()
metadata = json.loads(metadata)
info['name'] = metadata['name']
info['description'] = metadata['summary']
major_version, minor_version, _ = metadata['version'].split('.', 2)
major_version = int(major_version)
minor_version = int(minor_version)
if minor_version % 2:
info['series'] = 'latest'
info['branch'] = 'branch/default'
else:
info['series'] = '.'.join(metadata['version'].split('.', 2)[:2])
info['branch'] = 'branch/' + info['series']
return info
info = get_info()
html_theme = 'sphinx_book_theme'
html_theme_options = {
'logo': {
'alt_text': "Tryton Documentation",
'image_light': 'https://docs.tryton.org/logo-light.svg',
'image_dark': 'https://docs.tryton.org/logo-dark.svg',
'link': base_url,
},
'home_page_in_toc': True,
'repository_provider': 'gitlab',
'repository_url': 'https://code.tryton.org/tryton',
'repository_branch': info['branch'],
'use_source_button': True,
'use_edit_page_button': True,
'use_repository_button': True,
'use_download_button': False,
'path_to_docs': 'naiad/doc',
}
html_title = info['description']
master_doc = 'index'
project = info['name']
release = version = info['series']
default_role = 'ref'
highlight_language = 'none'
extensions = [
'sphinx_copybutton',
'sphinx.ext.intersphinx',
]
intersphinx_mapping = {
'python': ('https://docs.python.org/', None),
}
linkcheck_ignore = [r'/.*', r'https://demo.tryton.org/*']
del get_info, info, base_url, modules_url, trytond_url