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

Conversation

humitos
Copy link
Member

@humitos humitos commented Oct 4, 2022

Pretty simple implementation to track Sphinx's extensions and theme. This is not the best implementation, but I think it could be good as a first start.

The new doctool key added will have this shape:

  "doctool": {
    "extensions": [
      "readthedocs_ext.readthedocs",
      "notfound.extension",
      "autoapi.extension",
      "sphinx_tabs.tabs",
      "sphinx-prompt",
      "sphinxemoji.sphinxemoji"
    ],
    "name": "sphinx",
    "theme": "sphinx_rtd_theme"
  },

Closes #9627
Requires: readthedocs/readthedocs-sphinx-ext#117


📚 Documentation previews 📚

Pretty simple implementation to track Sphinx's extensions and theme.
This is not the best implementation, but I think it could be good as a first
start.

The new `doctool` key added will have this shape:

```
  "doctool": {
    "extensions": [
      "readthedocs_ext.readthedocs",
      "notfound.extension",
      "autoapi.extension",
      "sphinx_tabs.tabs",
      "sphinx-prompt",
      "sphinxemoji.sphinxemoji"
    ],
    "name": "sphinx",
    "theme": "sphinx_rtd_theme"
  },
```

Closes #9627
@humitos humitos requested a review from a team as a code owner October 4, 2022 15:28
@humitos humitos requested a review from stsewd October 4, 2022 15:28
readthedocs/telemetry/collectors.py Outdated Show resolved Hide resolved
readthedocs/telemetry/collectors.py Outdated Show resolved Hide resolved
Our extension is now dumping the data we want to consume here. So, we are just
reading that file and saving it as part of the `BuildData` object.
@humitos
Copy link
Member Author

humitos commented Oct 13, 2022

This is how it looks the output now that we are using app.extensions. Note that it considers all the extensions, including the default ones:

 "doctool": {
    "extensions": [
      "sphinx.ext.mathjax",
      "sphinx.builders.html",
      "sphinx.builders.applehelp",
      "sphinx.builders.changes",
      "sphinx.builders.epub3",
      "sphinx.builders.devhelp",
      "sphinx.builders.dummy",
      "sphinx.builders.gettext",
      "sphinx.builders.htmlhelp",
      "sphinx.builders.latex",
      "sphinx.builders.linkcheck",
      "sphinx.builders.manpage",
      "sphinx.builders.qthelp",
      "sphinx.builders.texinfo",
      "sphinx.builders.text",
      "sphinx.builders.websupport",
      "sphinx.builders.xml",
      "sphinx.config",
      "sphinx.domains.c",
      "sphinx.domains.changeset",
      "sphinx.domains.cpp",
      "sphinx.domains.javascript",
      "sphinx.domains.math",
      "sphinx.domains.python",
      "sphinx.domains.rst",
      "sphinx.domains.std",
      "sphinx.directives",
      "sphinx.directives.code",
      "sphinx.directives.other",
      "sphinx.directives.patches",
      "sphinx.extension",
      "sphinx.io",
      "sphinx.parsers",
      "sphinx.registry",
      "sphinx.roles",
      "sphinx.transforms.post_transforms",
      "sphinx.transforms.post_transforms.code",
      "sphinx.transforms.post_transforms.images",
      "sphinx.transforms.post_transforms.compat",
      "sphinx.util.compat",
      "sphinx.environment.collectors.dependencies",
      "sphinx.environment.collectors.asset",
      "sphinx.environment.collectors.metadata",
      "sphinx.environment.collectors.title",
      "sphinx.environment.collectors.toctree",
      "sphinx.environment.collectors.indexentries",
      "alabaster",
      "readthedocs_ext.readthedocs",
      "sphinx_autorun"
    ],
    "html_theme": "sphinx_rtd_theme",
    "name": "sphinx"
  },

@humitos
Copy link
Member Author

humitos commented Oct 13, 2022

It requires this diff to test it locally:

diff --git a/readthedocs/doc_builder/python_environments.py b/readthedocs/doc_builder/python_environments.py
index 1d2a8ffef..0bee30074 100644
--- a/readthedocs/doc_builder/python_environments.py
+++ b/readthedocs/doc_builder/python_environments.py
@@ -215,8 +215,10 @@ class Virtualenv(PythonEnvironment):
                 ),
                 self.project.get_feature_value(
                     Feature.USE_SPHINX_RTD_EXT_LATEST,
-                    positive='readthedocs-sphinx-ext',
-                    negative='readthedocs-sphinx-ext<2.2',
+                    # positive='readthedocs-sphinx-ext',
+                    # negative='readthedocs-sphinx-ext<2.2',
+                    positive='git+https://github.com/readthedocs/readthedocs-sphinx-ext@humitos/telemetry-extensions-theme#egg=readthedocs-sphinx-ext',
+                    negative='git+https://github.com/readthedocs/readthedocs-sphinx-ext@humitos/telemetry-extensions-theme#egg=readthedocs-sphinx-ext',
                 ),
             ])
             if not self.project.has_feature(Feature.USE_SPHINX_LATEST):

Copy link
Member

@ericholscher ericholscher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dislike adding more features to our extension, but I do feel like the Sphinx run is the right place to gather this data.

readthedocs/telemetry/collectors.py Show resolved Hide resolved
@humitos
Copy link
Member Author

humitos commented Oct 17, 2022

I dislike adding more features to our extension, but I do feel like the Sphinx run is the right place to gather this data.

Yeah. Also, this approach will only works while we have control over the builds and automatically install our extension. We could think about a different of doing this in the future, but I think it's fine for now.

@humitos humitos merged commit 575afb8 into main Oct 17, 2022
@humitos humitos deleted the humitos/telemetry-doctool-extensions-and-theme branch October 17, 2022 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Telemetry: track extensions and html_theme Sphinx variables
3 participants