2023-10-05 15:58:53 +00:00
import sys
sys . path . append ( ' ./ ' )
from custom_conf import *
2023-05-26 15:58:16 +00:00
# Configuration file for the Sphinx documentation builder.
2023-10-05 15:58:53 +00:00
# You should not do any modifications to this file. Put your custom
# configuration into the custom_conf.py file.
# If you need to change this file, contribute the changes upstream.
2023-05-26 15:58:16 +00:00
#
2023-10-05 15:58:53 +00:00
# For the full list of built-in configuration values, see the documentation:
2023-05-26 15:58:16 +00:00
# https://www.sphinx-doc.org/en/master/usage/configuration.html
2023-10-05 15:58:53 +00:00
############################################################
### Extensions
############################################################
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
extensions = [
' sphinx_design ' ,
' sphinx_tabs.tabs ' ,
' sphinx_reredirects ' ,
2024-01-10 15:04:39 +00:00
' canonical.youtube-links ' ,
' canonical.related-links ' ,
' canonical.custom-rst-roles ' ,
' canonical.terminal-output ' ,
2023-10-05 15:58:53 +00:00
' sphinx_copybutton ' ,
' sphinxext.opengraph ' ,
' myst_parser ' ,
' sphinxcontrib.jquery ' ,
' notfound.extension '
]
extensions . extend ( custom_extensions )
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
### Configuration for extensions
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# Additional MyST syntax
myst_enable_extensions = [
' substitution ' ,
' deflist '
]
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# Used for related links
if ' discourse ' in html_context :
html_context [ ' discourse_prefix ' ] = html_context [ ' discourse ' ] + ' /t/ '
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# The default for notfound_urls_prefix usually works, but not for
# documentation on documentation.ubuntu.com
if slug :
notfound_urls_prefix = ' / ' + slug + ' /en/latest/ '
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
notfound_context = {
' title ' : ' Page not found ' ,
' body ' : ' <h1>Page not found</h1> \n \n <p>Sorry, but the documentation page that you are looking for was not found.</p> \n <p>Documentation changes over time, and pages are moved around. We try to redirect you to the updated content where possible, but unfortunately, that didn \' t work this time (maybe because the content you were looking for does not exist in this version of the documentation).</p> \n <p>You can try to use the navigation to locate the content you \' re looking for, or search for a similar page.</p> \n ' ,
2023-07-06 22:40:35 +00:00
}
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# Default image for OGP (to prevent font errors, see
# https://github.com/canonical/sphinx-docs-starter-pack/pull/54 )
if not ' ogp_image ' in locals ( ) :
ogp_image = ' https://assets.ubuntu.com/v1/253da317-image-document-ubuntudocs.svg '
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
############################################################
### General configuration
############################################################
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
exclude_patterns = [
' _build ' ,
' Thumbs.db ' ,
' .DS_Store ' ,
' .sphinx ' ,
]
exclude_patterns . extend ( custom_excludes )
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
rst_epilog = '''
. . include : : / reuse / links . txt
'''
if ' custom_rst_epilog ' in locals ( ) :
rst_epilog = custom_rst_epilog
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
source_suffix = {
' .rst ' : ' restructuredtext ' ,
' .md ' : ' markdown ' ,
}
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
if not ' conf_py_path ' in html_context and ' github_folder ' in html_context :
html_context [ ' conf_py_path ' ] = html_context [ ' github_folder ' ]
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# For ignoring specific links
linkcheck_anchors_ignore_for_url = [
r ' https://github \ .com/.* '
2023-05-26 15:58:16 +00:00
]
2023-10-05 15:58:53 +00:00
linkcheck_anchors_ignore_for_url . extend ( custom_linkcheck_anchors_ignore_for_url )
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
############################################################
### Styling
############################################################
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# Find the current builder
builder = ' dirhtml '
if ' -b ' in sys . argv :
builder = sys . argv [ sys . argv . index ( ' -b ' ) + 1 ]
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# Setting templates_path for epub makes the build fail
if builder == ' dirhtml ' or builder == ' html ' :
templates_path = [ ' .sphinx/_templates ' ]
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
# Theme configuration
2023-05-26 15:58:16 +00:00
html_theme = ' furo '
2023-10-05 15:58:53 +00:00
html_last_updated_fmt = ' '
html_permalinks_icon = ' ¶ '
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
############################################################
### Additional files
############################################################
2023-05-26 15:58:16 +00:00
2023-10-05 15:58:53 +00:00
html_static_path = [ ' .sphinx/_static ' ]
2023-05-26 15:58:16 +00:00
html_css_files = [
2023-10-05 15:58:53 +00:00
' custom.css ' ,
' header.css ' ,
' github_issue_links.css ' ,
' furo_colors.css '
2023-05-26 15:58:16 +00:00
]
2023-10-05 15:58:53 +00:00
html_css_files . extend ( custom_html_css_files )
html_js_files = [ ' header-nav.js ' ]
if ' github_issues ' in html_context and html_context [ ' github_issues ' ] and not disable_feedback_button :
html_js_files . append ( ' github_issue_links.js ' )
html_js_files . extend ( custom_html_js_files )