docs: add custom html_template_vars extension

This commit is contained in:
bastimeyer 2022-08-14 16:21:22 +02:00 committed by Forrest
parent 156b6602f4
commit a7f442ae85
3 changed files with 32 additions and 1 deletions

View File

@ -3,7 +3,7 @@
<img class="sidebar-logo" src="{{ pathto('_static/' + logo, 1) }}" alt="{{ project }}"/>
</div>
<p class="sidebar-brand-text">{{ project }}</p>
<p class="sidebar-brand-oneliner">A command-line utility that extracts streams from various services and pipes them into a video player of choice.</p>
<p class="sidebar-brand-oneliner">{{ oneliner }}</p>
</a>
<div class="sidebar-versions centered" role="note" aria-label="versions">
<pre class="sidebar-versions-current">{{ release }}</pre>

View File

@ -20,6 +20,7 @@ extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.autosectionlabel',
'sphinx.ext.intersphinx',
'ext_html_template_vars',
'ext_argparse',
'ext_github',
'ext_plugins',
@ -129,6 +130,13 @@ html_theme_options = {
# Add any paths that contain custom themes here, relative to this directory.
#html_theme_path = []
# HTML template variables via the custom ext_html_template_vars extension
html_template_vars = {
"oneliner": (
"A command-line utility that extracts streams from various services and pipes them into a video player of choice."
),
}
# The name for this set of Sphinx documents. If None, it defaults to
# "<project> v<release> documentation".
#html_title = None

View File

@ -0,0 +1,23 @@
from typing import Any, Dict
from sphinx.addnodes import document
from sphinx.application import Sphinx
_CONFIG_VAR = "html_template_vars"
def update_context(
app: Sphinx,
pagename: str,
templatename: str,
context: Dict[str, Any],
doctree: document,
) -> None:
for k, v in getattr(app.config, _CONFIG_VAR).items():
context[k] = v
def setup(app: Sphinx) -> None:
app.add_config_value(_CONFIG_VAR, {}, "")
app.connect("html-page-context", update_context)