Skip to content

Fix equation rendering in Sphinx docs (closes #8)#14

Merged
AmeyaWagh merged 5 commits into
mainfrom
claude/fix-equation-rendering-EODK8
Apr 4, 2026
Merged

Fix equation rendering in Sphinx docs (closes #8)#14
AmeyaWagh merged 5 commits into
mainfrom
claude/fix-equation-rendering-EODK8

Conversation

@AmeyaWagh

@AmeyaWagh AmeyaWagh commented Apr 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pin Sphinx docs to MathJax v3 (Sphinx 9 defaults to v4, which broke equation rendering)
  • Add explicit mathjax3_config with display math settings and processHtmlClass
  • Convert all plain-text formula sections to proper RST .. math:: directives and :math: inline roles across all metric docstrings

Root Cause

Two separate issues caused equations not to render:

  1. MathJax v4 incompatibility (docs/source/conf.py): Sphinx 9 loads MathJax v4 by default. myst-parser's update_mathjax mechanism adds mathjax_ignore to content sections and relies on options.processHtmlClass to still render <div class="math"> nodes inside them. This works in MathJax v3 but breaks in v4. Fixed by pinning to MathJax v3.

  2. Plain-text formulas in docstrings: Several metric classes used a plain Formulas: block or bare ASCII math (e.g. SR = N_success / N_total) instead of RST math directives. Sphinx does not render these as LaTeX.

Files Changed

File Change
docs/source/conf.py Pin to MathJax v3; add mathjax3_config
task_performance/success_rate.py Plain-text → .. math::
task_performance/task_completion_rate.py Plain-text → .. math::
task_performance/action_accuracy.py Formulas: block → .. math:: directives
trajectory_quality/path_length.py Plain-text → .. math::
trajectory_quality/path_smoothness.py Plain-text → .. math::
trajectory_quality/curvature_change.py Plain-text (two formulas) → .. math::
trajectory_quality/absolute_trajectory_error.py Plain-text → .. math::
trajectory_quality/relative_trajectory_error.py Plain-text → .. math::

Test Plan

  • Build Sphinx docs: python -m sphinx docs/source docs/build/html -b html
  • Open docs/build/html/index.html — verify all equations in the Metrics Reference section render as formatted math
  • Open individual API pages (e.g. _autosummary/robometric_frame.task_performance.action_accuracy.html) — verify inline and display equations render correctly

https://claude.ai/code/session_014kBSLuJ9WpuxuQm9vbtm3C

claude added 4 commits April 4, 2026 17:17
Sphinx 9 defaults to MathJax v4, which changed the skipHtmlClass/processHtmlClass
interaction. myst-parser's update_mathjax adds mathjax_ignore to content sections
and relies on processHtmlClass to still render math nodes — this mechanism works
correctly in MathJax v3 but not v4. Pin to MathJax v3 and add an explicit
mathjax3_config with the correct tex delimiters and processHtmlClass setting.

Fixes #8

https://claude.ai/code/session_014kBSLuJ9WpuxuQm9vbtm3C
Replace the plain-text 'Formulas:' section with proper RST '.. math::'
display directives and ':math:' inline roles, matching the pattern used
in the safety metric docstrings. Previously the formulas rendered as raw
text in the Sphinx API docs.

https://claude.ai/code/session_014kBSLuJ9WpuxuQm9vbtm3C
Replace plain-text formula representations in all five trajectory quality
metric docstrings with proper RST '.. math::' display directives and
':math:' inline roles:

- PathLength: PL sum formula
- PathSmoothness: PS normalized sum formula
- CurvatureChange: CC and κ_i formulas
- AbsoluteTrajectoryError: ATE mean distance formula
- RelativeTrajectoryError: RTE relative motion formula

https://claude.ai/code/session_014kBSLuJ9WpuxuQm9vbtm3C
… as LaTeX

Replace plain-text formula representations with proper RST '.. math::'
display directives and ':math:' inline roles. Also add r-string prefix to
docstrings so LaTeX backslashes are not misinterpreted.

https://claude.ai/code/session_014kBSLuJ9WpuxuQm9vbtm3C
@AmeyaWagh AmeyaWagh changed the title Fix equation rendering in Sphinx docs by pinning to MathJax v3 Fix equation rendering in Sphinx docs (closes #8) Apr 4, 2026
Split the PS formula across two lines in the .. math:: block to stay
within the 100-character line length limit.

https://claude.ai/code/session_014kBSLuJ9WpuxuQm9vbtm3C
@AmeyaWagh AmeyaWagh merged commit e5fc211 into main Apr 4, 2026
8 checks passed
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.

2 participants