2026-08-09 13:44:20 -04:00
|
|
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
|
|
|
|
# this repository contains the full copyright notices and license terms.
|
|
|
|
|
|
2026-08-10 00:08:55 -04:00
|
|
|
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 configparser
|
|
|
|
|
import json
|
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
|
|
module_dir = os.path.dirname(os.path.dirname(__file__))
|
|
|
|
|
|
|
|
|
|
config = configparser.ConfigParser()
|
|
|
|
|
config.read_file(open(os.path.join(module_dir, 'tryton.cfg')))
|
|
|
|
|
info = dict(config.items('tryton'))
|
|
|
|
|
|
|
|
|
|
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']
|
|
|
|
|
|
|
|
|
|
for key in {'depends', 'extras_depend'}:
|
|
|
|
|
info[key] = info.get(key, '').strip().splitlines()
|
|
|
|
|
info['modules'] = set(info['depends'] + info['extras_depend'])
|
|
|
|
|
info['modules'] -= {'ir', 'res'}
|
|
|
|
|
|
|
|
|
|
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': 'modules/account_do/doc',
|
|
|
|
|
}
|
|
|
|
|
html_title = info['description']
|
|
|
|
|
master_doc = 'index'
|
|
|
|
|
project = info['name']
|
|
|
|
|
release = version = info['series']
|
2026-08-09 13:44:20 -04:00
|
|
|
default_role = 'ref'
|
|
|
|
|
highlight_language = 'none'
|
2026-08-10 00:08:55 -04:00
|
|
|
exclude_patterns = ['**/*.inc.rst']
|
2026-08-09 13:44:20 -04:00
|
|
|
extensions = [
|
2026-08-10 00:08:55 -04:00
|
|
|
'sphinx_copybutton',
|
2026-08-09 13:44:20 -04:00
|
|
|
'sphinx.ext.intersphinx',
|
|
|
|
|
]
|
|
|
|
|
intersphinx_mapping = {
|
2026-08-10 00:08:55 -04:00
|
|
|
'trytond': (trytond_url.format(series=version), None),
|
2026-08-09 13:44:20 -04:00
|
|
|
}
|
2026-08-10 00:08:55 -04:00
|
|
|
intersphinx_mapping.update({
|
|
|
|
|
module: (modules_url.format(
|
|
|
|
|
module=module.replace('_', '-'), series=version), None)
|
|
|
|
|
for module in info['modules']
|
|
|
|
|
})
|
|
|
|
|
linkcheck_ignore = [r'/.*', r'https://demo.tryton.org/*']
|
|
|
|
|
linkcheck_request_headers = {
|
|
|
|
|
'User-Agent': (
|
|
|
|
|
'TrytonBot/0.0 (https://www.tryton.org/foundation) '
|
|
|
|
|
'sphinx-linkcheck/0.0'),
|
|
|
|
|
'Accept-Encoding': 'gzip',
|
|
|
|
|
}
|
|
|
|
|
linkcheck_workers = 1
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
with open(os.path.join(
|
|
|
|
|
os.path.dirname(__file__),
|
|
|
|
|
'linkcheck_ignore.json'), 'r') as file:
|
|
|
|
|
import json
|
|
|
|
|
linkcheck_ignore.extend(json.load(file))
|
|
|
|
|
del json
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
del get_info, info, base_url, modules_url, trytond_url
|