Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry: track Sphinx extensions and html_theme variables #9639

Merged
merged 8 commits into from
Oct 17, 2022
32 changes: 32 additions & 0 deletions readthedocs/telemetry/collectors.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Data collectors."""

import json
import os

import dparse
import structlog
Expand Down Expand Up @@ -89,6 +90,37 @@ def collect(self):
"all": all_apt_packages,
},
}
data["doctool"] = self._get_doctool()
return data

def _get_doctool_name(self):
if self.version.is_sphinx_type:
return "sphinx"

if self.version.is_mkdocs_type:
return "mkdocs"

return "generic"

def _get_doctool(self):
data = {
"name": self._get_doctool_name(),
"extensions": [],
"html_theme": "",
}

if self._get_doctool_name() != "sphinx":
return data

conf_py_dir = os.path.join(
self.checkout_path,
os.path.dirname(self.config.sphinx.configuration),
)
filepath = os.path.join(conf_py_dir, "_build", "json", "telemetry.json")
if os.path.exists(filepath):
with open(filepath, "r") as json_file:
content = json_file.read()
data.update(self._safe_json_loads(content, {}))
humitos marked this conversation as resolved.
Show resolved Hide resolved
return data

def _get_all_conda_packages(self):
Expand Down