Skip to content

Commit

Permalink
Add HTML snippet for Plausible metrics
Browse files Browse the repository at this point in the history
Metrics are only collected for the main packaging.python.org
documentation deployments.

Closes #1561
  • Loading branch information
ncoghlan authored Jun 19, 2024
1 parent 7195af6 commit 82280c0
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions source/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# -- Project information ---------------------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information

import os

# Some options are only enabled for the main packaging.python.org deployment builds
RTD_BUILD = bool(os.getenv("READTHEDOCS"))
RTD_PR_BUILD = RTD_BUILD and os.getenv("READTHEDOCS_VERSION_TYPE") == "external"
RTD_URL = os.getenv("READTHEDOCS_CANONICAL_URL")
RTD_CANONICAL_BUILD = RTD_BUILD and not RTD_PR_BUILD and "packaging.python.org" in RTD_URL

project = "Python Packaging User Guide"

copyright = "2013–2020, PyPA"
Expand Down Expand Up @@ -55,6 +63,15 @@
html_favicon = "assets/py.png"
html_last_updated_fmt = ""

_metrics_js_files = [
("https://plausible.io/js/script.js", {"data-domain": "packaging.python.org"})
]
html_js_files = []
if RTD_CANONICAL_BUILD:
# Enable collection of the visitor metrics reported at
# https://plausible.io/packaging.python.org
html_js_files.extend(_metrics_js_files)

# -- Options for HTML help output ------------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-help-output

Expand Down

0 comments on commit 82280c0

Please sign in to comment.