0xHiteshPatel / sphinxcontrib-addmetahtml

Sphinx extension that enables addition of user-defined HTML to docs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add META HTML extension for Sphinx

Author: Hitesh Patel <hp@hiteshpatel.net>

Overview

Sphinx extension that enables addition of user-defined HTML to docs. Inspired by sphinxcontrib-googleanalytics but a much more generic functionality.

Installation

Manual

git clone https://github.com/0xHiteshPatel/sphinxcontrib-addmetahtml.git

cd sphinxcontrib-addmetahtml

python setup.py install

pip requirements.txt

echo 'git+git://github.com/0xHiteshPatel/sphinxcontrib-addmetahtml@master#egg=sphinxcontrib-addmetahtml' >> requirements.txt

Configuration

  1. Add to extensions list in conf.py:

    extensions += ['sphinxcontrib.addmetahtml']

  2. The extension is enabled by default. Set the content to add to docs generated by the html builder:

    addmetahtml_content = <string>

  3. To disable the extension:

    addmetahtml_enabled = False

Examples

Add Google Analytics ID

addmetahtml_content = """<script async src="https://www.googletagmanager.com/gtag/js?id=UA-0000000-0"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'UA-0000000-0');
</script>"""

About

Sphinx extension that enables addition of user-defined HTML to docs

License:BSD 2-Clause "Simplified" License


Languages

Language:Python 100.0%