You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ORPA-pyOpenRPA/Resources/WPy64-3720/python-3.7.2.amd64/Lib/site-packages/sphinxcontrib_addmetahtml-0.../sphinxcontrib/addmetahtml.py

28 lines
781 B

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sphinx.errors import ExtensionError
def insert_content(app, pagename, templatename, context, doctree):
if not app.config.addmetahtml_enabled:
return
metatags = context.get('metatags', '')
metatags += app.config.addmetahtml_content
context['metatags'] = metatags
def validate_config(app):
if not app.config.addmetahtml_content:
raise ExtensionError("Please set a value for 'addmetahtml_content'")
def setup(app):
app.add_config_value('addmetahtml_enabled', True, 'html')
app.add_config_value('addmetahtml_content', '', 'html')
app.connect('builder-inited', validate_config)
app.connect('html-page-context', insert_content)
return
{
'version': '0.1.1'
}