Skip to content

Fix static doc viewing in IDEs - #14195

Merged
larsoner merged 9 commits into
mne-tools:mainfrom
larsoner:static-docs
Sep 15, 2026
Merged

larsoner merged 9 commits into
mne-tools:mainfrom
larsoner:static-docs

Conversation

@larsoner

Copy link
Copy Markdown
Member

The goals of this PR are to eventually:

  1. Make it so that docstrings are rendered properly in IDEs by filling out all of them
  2. Keep docdict as the source of truth for multiple docstrings (good for blame, and existing workflows)
  3. Use a pre-commit hook to ensure docstrings don't drift -- if docdict is modified, update all matches (preserve old dev behavior); but also add a new one: if a single matching docstring is modified, modify docdict and all others (no longer have to open docs.py to edit a shared docstring, can edit inplace and have it propagate). # noqa: E501s are added/removed as needed (e.g., if the docdict entry is unindented and runs to 87 char, the indented version will need the noqa line).
  4. Preserve exising fill_doc/verbose/copy_*_to_* as these are used in MNE-BIDS and MNE-Connectivity (and low cost to keep here)

The diff looks scary, but of the ~1800 lines added only ~700 are the hook machinery, the rest is tests plus filled-in-docstring etc. This PR only implements these changes for a representative subset of docstrings that hopefully captures all of our fill_doc/verbose use cases. Assuming we're happy with the results, we can merge this, then I'll open a second PR that changes all docdict'ed docstrings to use this method (so that we can .git-blame-revs-ignore it after it merges).

These changes require some doc parsing logic, but it's not too bad. If we require that all these entries start on a given line at a given indentation level and don't decrease that level, it's doable. (There are some cases that are tough to disambiguate in the propagate-back-to-docdict case, and if it can't, then it will just raise an error and not try, similar to other pre-commit hooks when they cannot automatically fix things.)

Iterated multiple times through with Claude Fable 5. Changes understood by me. I plan to review more carefully in the coming days but wanted to get a WIP PR going in the meantime.

First part of two-part approach to #8218

@larsoner larsoner modified the milestone: 1.13 Aug 31, 2026
@larsoner
larsoner marked this pull request as ready for review September 15, 2026 19:38
@larsoner
larsoner enabled auto-merge (squash) September 15, 2026 20:56
@larsoner

Copy link
Copy Markdown
Member Author

Spoke with @drammock today and we're going to give this a shot, and eventually probably rework the docdict backend to make it simpler. But in the meantime this should solve the IDE problem hopefully (at least once the huge follow-up is in with the docstring updates)! 🤞

@larsoner
larsoner merged commit 0311e44 into mne-tools:main Sep 15, 2026
26 checks passed
@larsoner
larsoner deleted the static-docs branch September 15, 2026 22:26
@cbrnr

cbrnr commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

This is a great change! Looking forward to finally being able to read the docstrings in my IDE! Thanks @larsoner!

larsoner added a commit to wmvanvliet/mne-python that referenced this pull request Sep 16, 2026
…d-sphere

* commit '0311e444b0450ce9d2b2b304cebe7d5343533357':
  Fix static doc viewing in IDEs (mne-tools#14195)
  Fix COLA for odd sizes (mne-tools#14312)
  add type hints to mne/_fiff/ module (mne-tools#14278)
  ENH: wire the JupyterLite build into the docs (JupyterLite split 5/5) (mne-tools#14157)
  MAINT: Update pre-commit hook versions (mne-tools#14306)
  Small documentation fix for "Frequency and time-frequency sensor analysis" tutorial (mne-tools#14304)
  FIX: don't mutate cached ICA sources in plot_sources properties (mne-tools#14303)
  Fix bug with lite backend closing (mne-tools#14302)
  Fix for NumPy eig change [circle deploy] (mne-tools#14300)
  No PyQt5 [circle deploy] [skip azp] [skip actions]
  ENH: add the JupyterLite notebook setup cell (JupyterLite split 4/5) (mne-tools#14150)
  FIX: Ver [circle deploy] [skip azp] [skip actions]
  Hotfix
  fix EDF round-trip (mne-tools#14296)
  Brain GUI modernization (Phase 7) (mne-tools#14270)
  Fix bug with SciPy 1.18.0 EEGLAB reading (mne-tools#14293)
  remove plotting abs as the defauls for plotting volumetric (mne-tools#13989)
  Coregistration GUI modernisation (phase 4) (mne-tools#14285)
  Dipole GUI interactivity and visual enhancements (phase 2) (mne-tools#14291)
larsoner added a commit to CarinaFo/mne-python that referenced this pull request Sep 16, 2026
* upstream/main: (91 commits)
  Fix static doc viewing in IDEs (mne-tools#14195)
  Fix COLA for odd sizes (mne-tools#14312)
  add type hints to mne/_fiff/ module (mne-tools#14278)
  ENH: wire the JupyterLite build into the docs (JupyterLite split 5/5) (mne-tools#14157)
  MAINT: Update pre-commit hook versions (mne-tools#14306)
  Small documentation fix for "Frequency and time-frequency sensor analysis" tutorial (mne-tools#14304)
  FIX: don't mutate cached ICA sources in plot_sources properties (mne-tools#14303)
  Fix bug with lite backend closing (mne-tools#14302)
  Fix for NumPy eig change [circle deploy] (mne-tools#14300)
  No PyQt5 [circle deploy] [skip azp] [skip actions]
  ENH: add the JupyterLite notebook setup cell (JupyterLite split 4/5) (mne-tools#14150)
  FIX: Ver [circle deploy] [skip azp] [skip actions]
  Hotfix
  fix EDF round-trip (mne-tools#14296)
  Brain GUI modernization (Phase 7) (mne-tools#14270)
  Fix bug with SciPy 1.18.0 EEGLAB reading (mne-tools#14293)
  remove plotting abs as the defauls for plotting volumetric (mne-tools#13989)
  Coregistration GUI modernisation (phase 4) (mne-tools#14285)
  Dipole GUI interactivity and visual enhancements (phase 2) (mne-tools#14291)
  Width [circle deploy] [skip azp] [skip actions]
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants