3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-05 05:33:49 +01:00
dft_tools/doc/conf.py.in

144 lines
4.6 KiB
Python
Raw Normal View History

2013-08-07 16:40:18 +02:00
# -*- coding: utf-8 -*-
#
2013-09-01 17:56:17 +02:00
# TRIQS documentation build configuration file
2013-08-07 16:40:18 +02:00
import sys
sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext")
sys.path.insert(0, "@CMAKE_CURRENT_SOURCE_DIR@/sphinxext/numpydoc")
2018-09-10 10:56:37 +02:00
sys.path.insert(0, "@CMAKE_BINARY_DIR@/python")
2022-02-16 15:16:49 +01:00
# exclude these folders from scanning by sphinx
exclude_patterns = ['_templates']
2013-09-01 17:56:17 +02:00
extensions = ['sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.intersphinx',
'sphinx.ext.doctest',
'sphinx.ext.todo',
'sphinx.ext.viewcode',
'sphinx.ext.autosummary',
'sphinx.ext.githubpages',
'sphinx_autorun',
2021-08-02 19:43:07 +02:00
'nbsphinx',
'myst_parser',
'matplotlib.sphinxext.plot_directive',
'nbsphinx',
'IPython.sphinxext.ipython_console_highlighting',
'numpydoc']
2013-08-07 16:40:18 +02:00
myst_enable_extensions = [
"amsmath",
"colon_fence",
"deflist",
"dollarmath",
"html_admonition",
"html_image",
"linkify",
"replacements",
"smartquotes",
"substitution",
"tasklist",
]
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
2013-08-07 16:40:18 +02:00
source_suffix = '.rst'
2022-02-16 15:16:49 +01:00
# Turn on sphinx.ext.autosummary
autosummary_generate = True
autosummary_imported_members=False
2021-09-17 20:24:22 +02:00
project = 'TRIQS DFTTools'
version = '@PROJECT_VERSION@'
# this makes the current project version available as var in every rst file
rst_epilog = """
.. |PROJECT_VERSION| replace:: {version}
""".format(
version = version,
)
2021-09-17 20:24:22 +02:00
copyright = '2011-2021'
2013-08-07 16:40:18 +02:00
2020-08-10 17:07:05 +02:00
mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=default"
templates_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_templates']
2013-08-07 16:40:18 +02:00
2021-08-02 19:43:07 +02:00
# this requires the sphinx_rtd_theme to be installed via pip
html_theme = 'sphinx_rtd_theme'
# this loads the custom css file to change the page width
html_style = 'css/custom.css'
#html_favicon = '@CMAKE_CURRENT_SOURCE_DIR@/logos/favicon.ico'
#html_logo = '@CMAKE_CURRENT_SOURCE_DIR@/logos/logo.png'
2021-08-02 19:43:07 +02:00
# options for the the rtd theme
html_theme_options = {
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'style_external_links': False,
'vcs_pageview_mode': '',
'style_nav_header_background': '#7E588A',
2021-08-02 19:43:07 +02:00
# Toc options
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': 4,
2021-08-02 19:43:07 +02:00
'includehidden': True,
'titles_only': False
}
2013-09-01 17:56:17 +02:00
html_show_sphinx = False
2021-08-02 19:43:07 +02:00
2021-09-17 20:24:22 +02:00
html_context = {'header_title': 'TRIQS DFTTools'}
2021-08-02 19:43:07 +02:00
html_static_path = ['@CMAKE_CURRENT_SOURCE_DIR@/_static']
2013-09-04 16:54:45 +02:00
html_sidebars = {'index': ['sideb.html', 'searchbox.html']}
2013-09-01 17:56:17 +02:00
htmlhelp_basename = '@PROJECT_NAME@doc'
2013-09-01 17:56:17 +02:00
intersphinx_mapping = {'python': ('https://docs.python.org/3.8', None), 'triqslibs': ('https://triqs.github.io/triqs/latest', None)}
2021-08-02 19:43:07 +02:00
# open links in new tab instead of same window
from sphinx.writers.html import HTMLTranslator
from docutils import nodes
from docutils.nodes import Element
class PatchedHTMLTranslator(HTMLTranslator):
def visit_reference(self, node: Element) -> None:
atts = {'class': 'reference'}
if node.get('internal') or 'refuri' not in node:
atts['class'] += ' internal'
else:
atts['class'] += ' external'
# ---------------------------------------------------------
# Customize behavior (open in new tab, secure linking site)
atts['target'] = '_blank'
atts['rel'] = 'noopener noreferrer'
# ---------------------------------------------------------
if 'refuri' in node:
atts['href'] = node['refuri'] or '#'
if self.settings.cloak_email_addresses and atts['href'].startswith('mailto:'):
atts['href'] = self.cloak_mailto(atts['href'])
self.in_mailto = True
else:
assert 'refid' in node, \
'References must have "refuri" or "refid" attribute.'
atts['href'] = '#' + node['refid']
if not isinstance(node.parent, nodes.TextElement):
assert len(node) == 1 and isinstance(node[0], nodes.image)
atts['class'] += ' image-reference'
if 'reftitle' in node:
atts['title'] = node['reftitle']
if 'target' in node:
atts['target'] = node['target']
self.body.append(self.starttag(node, 'a', '', **atts))
if node.get('secnumber'):
self.body.append(('%s' + self.secnumber_suffix) %
'.'.join(map(str, node['secnumber'])))
def setup(app):
app.set_translator('html', PatchedHTMLTranslator)