Repository navigation
docs: fix Sphinx build warnings; restore richards.cADR extension (1.9.x) - #43
Merged
Merged
Conversation
'\input{macros}' triggered a SyntaxWarning ("\i" is an invalid escape
sequence) under current Python; make it a raw string.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PcVEQMRyBkdnv6pDKykJRt
This was referenced Oct 12, 2026
… bug Drives docs_build warnings from 104 down to 3 (0 errors, build succeeds clean). Root-caused via napoleon+docutils isolation testing, not just grepped from the build log. Real bugs (not cosmetic): - proteus/richards/ADR.py does `from .cADR import *`, but the richards.cADR Extension entry was dropped from setup.py in merge 9e2aca5 (2026-08-12), leaving richards.ADR unimportable. Restored it, mirroring richards.cRichards (erdc#1285). - Several docstrings (PresInc.Coefficients, PostProcessingTools, SubgridError, TimeIntegration, mprans/Pres.Coefficients) used LaTeX like \nabla/\tau/\theta/\rho in a non-raw string -- Python silently interpreted \n/\t/\r as real newline/tab/CR characters, corrupting the docstring content itself, not just its RST rendering. Fixed with r""" in each case, same class of bug as the conf.py `\input` fix. - docs/Makefile's sphinx-apidoc invocation tried to autodoc proteus/flcbdfWrappers.pyx (extension commented out in setup.py, no compiled .so exists) and proteus/SWFlow/utils/SWEs_so.py (a parun-driven split-operator script that sniffs sys.argv and __import__()s a case file by name -- fails outside of parun). Excluded both from the apidoc scan. Cosmetic (widespread but mechanical): missing blank lines before numpydoc `Parameters`/`Returns`/`Notes` headers, mismatched continuation indentation, bullet/definition lists glued to a preceding paragraph without a blank line, a bare `.. math:` (single colon, not a directive at all), `-mavx`-unrelated stray formatting -- across LinearAlgebraTools, LinearSolvers, FemTools, NonlinearSolvers, SimTools, StepControl, Viewers, WaveTools, mbd/CouplingFSI, mprans/{BodyDynamics, BoundaryConditions,MoveMeshMonitor}. Also dropped three vestigial `.. inheritance-diagram::` directives (DiagUtils, EGeometry, Norms, RefUtils) pointing at modules that define no classes at all. Doc-build plumbing: apidoc's default modules.rst index page is never linked from this project's toctree (apicapi.rst hyperlinks straight to api/proteus.html instead) -- generating it produced a permanent "not included in any toctree" warning. Switched to `--no-toc` and marked the new orphan (api/proteus.rst itself, only reached via that same bare hyperlink) with `:orphan:` via a package.rst_t template tweak, scoped to just the top-level package page. Also removed sphinx_rtd_theme's removed `display_version` option, fixed a `:doc:` link to a boundary_conditions page that doesn't exist. The inheritance-diagram directives that do have classes need graphviz's `dot` to render; that was present in the env this was tested in but is not added here (see the follow-up commit). Remaining 3 warnings, investigated and left as genuinely benign: - TI_base:1 -- isolated napoleon+docutils reproduction of this exact docstring (alone, and combined with __init__'s per autoclass_content='both') parses with zero warnings; a minimal standalone Sphinx project autodoc-ing just this class also reproduces nothing. Sphinx's location attribution for this one appears to be wrong in the full build, not a real defect in the referenced content. - WaveTools.NewWave.phi / WaveTools.RandomWaves.phi -- an ambiguous cross-reference between two sibling classes' identically-named attributes; no specific docstring line introduces it via an explicit role, so there's no single place to point a fix at. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PcVEQMRyBkdnv6pDKykJRt
Docstring math uses custom macros (\deld, \grad, \ten, \pd, \od, \mat,
\outer, \ds) that were never defined for the HTML build, so MathJax drew
93 of them as red "\grad"-style text with no build warning. The LaTeX
preamble did `\input{macros}`, a file that is not in the repo. Define
them once in conf.py (math_macros) and generate both mathjax3_config
and the LaTeX preamble from that. Drop the unused `mathjax_pth`.
Make 17 more docstrings raw that still had \v, \f, \a, \b, \t or \r
turned into control characters (\vec, \frac, \alpha, \beta, \tau/\ten),
the same bug class as the previous commit. Only docstrings change: each
file's AST with docstrings blanked is identical before and after.
Fix TeX errors MathJax reported: \left( closed by `)` and \frac{1}{rho}
in the k-epsilon docstrings, `\ten \bar{D}` -> `\ten{\bar{D}}`, Python
`%` (a TeX comment) -> \bmod in three PostProcessingTools formulas, and
the \lamda/\alph typos. Restore TI_base's equation as math.
All 206 formulas in proteus docstrings now typeset in MathJax 3 with no
errors and no undefined macros.
Add graphviz to environment-dev-up.yml, which the inheritance diagrams
need for `dot`, and make `make docs` fail if `dot` is missing rather
than silently drop the diagrams.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cekees
force-pushed
the
docfix-sphinx-warnings-1.9.x
branch
from
October 13, 2026 08:02
bd779c8 to
9eb0efd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Your
docfix-sphinx-warningsbranch (3dac55e + 6f21604), cherry-picked onto 1.9.x, with two changes:futureaddition toenvironment-dev-up.yml. It existed only forpast.utils.old_divinrichards/ADR.py, which Replace past.utils.old_div with true division (1.9.x) #41 (already merged into 1.9.x) replaced with/.richards.cADR"never" had an Extension entry. It did, from 2024 (079a0b4) until merge 9e2aca5 dropped it on 2026-08-12. Both now say that and point to proteus.richards.ADR is unimportable: richards.cADR extension not built erdc/proteus#1285.Everything else is unchanged: the Sphinx warning fixes (104 → 3), the raw-string fixes for LaTeX docstrings whose
\n/\t/\rwere being interpreted as escapes, the apidoc exclusions, and the restoredrichards.cADRExtension.About the restored extension
proteus/richards/cADR.cppcompiles with the entry as written (checked standalone with clang 21 and libc++;-Iproteus/richardsisn't needed). With it built,import proteus.richards.ADRworks.test/richards/adr_1dthrough it fails ingetResidual. ThreeargsDict["elementMaterialTypes"] = ...,lines have trailing commas that make the value a tuple, and after fixing those,delta_x_ijisNone.richards.ADRbegan as a skeleton and isn't finished. That work is tracked in proteus.richards.ADR is unimportable: richards.cADR extension not built erdc/proteus#1285; this PR only makes the module importable and gets it through the docs build.Docstring math and graphviz (9eb0efd)
\deld,\grad,\ten,\pd,\od,\mat,\outer,\dsare now defined once inconf.py(math_macros).mathjax3_configand the LaTeX preamble are both generated from it; the preamble used to\input{macros}, a file that isn't in the repo. Without the definitions, MathJax drew 93 of these as red\grad-style text and Sphinx gave no warning.\vec/\frac/\alpha/\beta/\tauturned into control characters, the same bug the first commit fixed elsewhere. Only docstrings changed: the AST with docstrings blanked is identical before and after.\left(without\right)and{rho}in the k-epsilon docs,\ten \bar{D}→\ten{\bar{D}}, Python%(a TeX comment) →\bmod, and the\lamda/\alphtypos.TI_base's equation is math again.environment-dev-up.yml; the 35 modules with inheritance diagrams needdot.make docsnow fails ifdotis missing instead of silently dropping the diagrams. The four diagrams removed earlier (DiagUtils, EGeometry, Norms, RefUtils) warn "No classes found" whether or notdotis present, so removing them was correct.Testing
.pyfiles passpy_compilewith-W error::SyntaxWarning.The branch also applies cleanly to main; I'll forward-port it if you want it there too.
🤖 Generated with Claude Code