Files
tryton/modules/account_product/doc/conf.py
T

114 lines
3.4 KiB
Python
Raw Normal View History

2021-01-05 16:44:34 +00: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.
2022-12-16 23:16:08 +01: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/'
2021-01-05 16:44:34 +00:00
def get_info():
import configparser
import subprocess
import sys
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'))
result = subprocess.run(
2023-09-01 09:44:09 +02:00
[sys.executable, 'setup.py', '--name', '--description'],
2021-01-05 16:44:34 +00:00
stdout=subprocess.PIPE, check=True, cwd=module_dir)
2023-09-01 09:44:09 +02:00
info['name'], info['description'] = (
result.stdout.decode('utf-8').strip().splitlines())
2021-01-05 16:44:34 +00:00
result = subprocess.run(
[sys.executable, 'setup.py', '--version'],
stdout=subprocess.PIPE, check=True, cwd=module_dir)
version = result.stdout.decode('utf-8').strip()
major_version, minor_version, _ = version.split('.', 2)
major_version = int(major_version)
minor_version = int(minor_version)
if minor_version % 2:
2021-01-05 16:44:34 +00:00
info['series'] = 'latest'
2023-09-01 09:44:09 +02:00
info['branch'] = 'branch/default'
2021-01-05 16:44:34 +00:00
else:
info['series'] = '.'.join(version.split('.', 2)[:2])
2023-09-01 09:44:09 +02:00
info['branch'] = 'branch/' + info['series']
2021-01-05 16:44:34 +00:00
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()
2023-09-01 09:44:09 +02:00
html_theme = 'sphinx_book_theme'
html_theme_options = {
'logo': {
2025-02-28 00:49:48 +01:00
'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,
2023-09-01 09:44:09 +02:00
'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_product/doc',
}
html_title = info['description']
2021-01-05 16:44:34 +00:00
master_doc = 'index'
project = info['name']
release = version = info['series']
default_role = 'ref'
highlight_language = 'none'
exclude_patterns = ['**/*.inc.rst']
2021-01-05 16:44:34 +00:00
extensions = [
2023-09-01 09:44:09 +02:00
'sphinx_copybutton',
2021-01-05 16:44:34 +00:00
'sphinx.ext.intersphinx',
]
intersphinx_mapping = {
'trytond': (trytond_url.format(series=version), None),
}
intersphinx_mapping.update({
m: (modules_url.format(
module=m.replace('_', '-'), series=version), None)
for m in info['modules']
})
2022-12-16 23:16:08 +01:00
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
2021-01-05 16:44:34 +00:00
try:
with open(os.path.join(
os.path.dirname(__file__),
'linkcheck_ignore.json'), 'r') as f:
import json
linkcheck_ignore.extend(json.load(f))
del json
except FileNotFoundError:
pass
2022-12-16 23:16:08 +01:00
del get_info, info, base_url, modules_url, trytond_url