From 4cdc054cb7baceb156d4ce5b82ad15805cecc857 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Tue, 23 Aug 2022 09:15:11 +0200 Subject: [PATCH] DOC Switch to Plausible analytics in the docs (#3004) --- docs/_templates/layout.html | 7 +++++++ docs/conf.py | 15 +++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 docs/_templates/layout.html diff --git a/docs/_templates/layout.html b/docs/_templates/layout.html new file mode 100644 index 000000000..210530ad5 --- /dev/null +++ b/docs/_templates/layout.html @@ -0,0 +1,7 @@ +{% extends '!layout.html' %} {%- block extrahead %} {{ super() }} + +{%- endblock %} diff --git a/docs/conf.py b/docs/conf.py index c9c47ce62..ebb8f25a1 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -146,6 +146,21 @@ if IN_READTHEDOCS: encoding="utf-8", ) print(res) + # insert the Plausible analytics script to console.html + console_path = Path("_build/html/console.html") + console_html = console_path.read_text().splitlines(keepends=True) + for idx, line in enumerate(list(console_html)): + if 'pyodide.js">' in line: + # insert the analytics script after the `pyodide.js` script + console_html.insert( + idx, + '\n', + ) + break + else: + raise ValueError("Could not find pyodide.js in the section") + console_path.write_text("".join(console_html)) + if IN_SPHINX: # Compatibility shims. sphinx-js and sphinxcontrib-napoleon have not been updated for Python 3.10