10000 [DRAFT]: ENH, DOC: Add JupyterLite-powered interactivity for the `statsmodels` documentation by agriyakhetarpal · Pull Request #9536 · statsmodels/statsmodels · GitHub
[go: up one dir, main page]

Skip to content

[DRAFT]: ENH, DOC: Add JupyterLite-powered interactivity for the statsmodels documentation #9536

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

Draft
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

agriyakhetarpal
Copy link
Contributor
@agriyakhetarpal agriyakhetarpal commented Mar 17, 2025

Notes:

  • It is essential that you add a test when making code changes. Tests are not
    needed for doc changes.
  • When adding a new function, test values should usually be verified in another package (e.g., R/SAS/Stata).
  • When fixing a bug, you must add a test that would produce the bug in main and
    then show that it is fixed with the new code.
  • New code additions must be well formatted. Changes should pass flake8. If on Linux or OSX, you can
    verify you changes are well formatted by running
    git diff upstream/main -u -- "*.py" | flake8 --diff --isolated
    
    assuming flake8 is installed. This command is also available on Windows
    using the Windows System for Linux once flake8 is installed in the
    local Linux environment. While passing this test is not required, it is good practice and it help
    improve code quality in statsmodels.
  • Docstring additions must render correctly, including escapes and LaTeX.

TODO:

Tasks to get interactive documentation components for the "API reference" pages ready:

  • Enable scaffolding for the TryExamples directive
  • Add necessary JupyterLite deployment configuration files
  • Ensure that the examples render properly in their notebooks
  • (Partially handled,so far): Styling of the "Try it!" buttons in accordance with the sphinx-immaterial theme
  • Patch statsmodels.datasets.get_rdataset to use pyodide.http.pyfetch APIs when running in the browser – this is an alternative approach to Patch statsmodels.datasets.get_rdataset network access pyodide/pyodide#5520
  • Ensure that the enabled examples are all self-contained – possibly modify the doctest runner for this or use notebook modification functions from jupyterlite-sphinx.
  • Find out which examples need to be disabled, and disable them

Ancillary tasks, towards making the "User Guide" interactive – which may be taken up in a follow-up PR as needed, so that this PR is better scoped:

  • Add JupyterLite-specific code at the top of notebooks (which won't be executed outside WASM)
  • Modify nbgenerate.py so that it doesn't include said JupyterLite-specific code in corresponding .py files
  • Get nbsphinx to not execute said cell in the notebooks and hide it in the built documentation
  • Test out notebooks to check which of them work in WASM and which do/won't
  • Use the nbsphinx_prolog/nbsphinx_epilog configuration option(s) to add a "Try it online" button at the top/bottom of every notebook, except for those that won't work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0