Skip to content

Commit 3163062

Browse files
authored
Merge pull request #1564 from ncoghlan/add-plausible-metrics
Add HTML snippet for Plausible metrics
2 parents 641fd24 + 303c248 commit 3163062

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

source/conf.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
# -- Project information ---------------------------------------------------------------
22
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
33

4+
import os
5+
6+
# Some options are only enabled for the main packaging.python.org deployment builds
7+
RTD_BUILD = bool(os.getenv("READTHEDOCS"))
8+
RTD_PR_BUILD = RTD_BUILD and os.getenv("READTHEDOCS_VERSION_TYPE") == "external"
9+
RTD_URL = os.getenv("READTHEDOCS_CANONICAL_URL")
10+
RTD_CANONICAL_BUILD = (
11+
RTD_BUILD and not RTD_PR_BUILD and "packaging.python.org" in RTD_URL
12+
)
13+
414
project = "Python Packaging User Guide"
515

616
copyright = "2013–2020, PyPA"
@@ -55,6 +65,18 @@
5565
html_favicon = "assets/py.png"
5666
html_last_updated_fmt = ""
5767

68+
_metrics_js_files = [
69+
(
70+
"https://plausible.io/js/script.js",
71+
{"data-domain": "packaging.python.org", "defer": "defer"},
72+
)
73+
]
74+
html_js_files = []
75+
if RTD_CANONICAL_BUILD:
76+
# Enable collection of the visitor metrics reported at
77+
# https://plausible.io/packaging.python.org
78+
html_js_files.extend(_metrics_js_files)
79+
5880
# -- Options for HTML help output ------------------------------------------------------
5981
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-help-output
6082

0 commit comments

Comments
 (0)