Skip to content

Document dataclass fields that ship as bare autodoc stubs#721

Merged
tony merged 7 commits into
masterfrom
attributes-backfill
Jul 26, 2026
Merged

Document dataclass fields that ship as bare autodoc stubs#721
tony merged 7 commits into
masterfrom
attributes-backfill

Conversation

@tony

@tony tony commented Jul 25, 2026

Copy link
Copy Markdown
Member

Autodoc renders every field of a dataclass whether or not the docstring describes it, so a field no Attributes section names reaches the API reference bare, and a NamedTuple field reaches it as "Alias for field number 0". This adds NumPy Attributes sections to the classes that predate the AGENTS.md rule requiring one: the option and hook containers in libtmux._internal.constants, Obj in libtmux.neo, and the scope and server fields on Pane, Session, and Window. Each entry names the field's type, what it holds, which tmux option or format token it maps to, and what its default or empty value means. Docstrings only — no code, signature, or field-order changes.

Gates run and passing: just ruff-format, just ruff, uv run mypy ., just test, just build-docs.

The docs build, warning-free on trunk, now reports a duplicate object description for each newly described field (duplicate object description of ..., use :no-index: for one of them). The NumPy preprocessor emits an .. attribute:: for each Attributes entry while autodoc also renders the field, so both register the same object. The build still succeeds. Left unsuppressed here deliberately: the fix belongs in the preprocessor upstream in gp-sphinx, not in a suppress_warnings entry in docs/conf.py.

Closes #720

@codecov

codecov Bot commented Jul 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 52.36%. Comparing base (325681b) to head (851e95f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #721   +/-   ##
=======================================
  Coverage   52.36%   52.36%           
=======================================
  Files          26       26           
  Lines        3726     3726           
  Branches      747      747           
=======================================
  Hits         1951     1951           
  Misses       1471     1471           
  Partials      304      304           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@tony
tony force-pushed the attributes-backfill branch from 0e5bf65 to c4fa6ca Compare July 26, 2026 00:57
tony added 7 commits July 25, 2026 20:20
why: autodoc renders every dataclass field whether or not it is
described, so the hook fields reach the API reference bare with no
indication of when tmux fires them. The man-page text already sits
beside each field as a source comment, invisible to readers of the
published docs.

what:
- Add an Attributes section to Hooks covering every hook field
- Note that an empty SparseArray means tmux reported no commands
why: autodoc renders every dataclass field whether or not it is
described, so the server, session, window, and pane option fields
reach the API reference bare. Readers cannot tell what a field
controls without opening the tmux man page and translating the
underscored name back to its hyphenated option.

what:
- Add Attributes sections to ServerOptions, SessionOptions,
  WindowOptions, and PaneOptions describing each option field
- Note in each summary that a field keeps its default when tmux
  reports no value for that option
why: autodoc renders every dataclass field whether or not it is
described, so Obj's tmux format fields reach the API reference bare,
both on Obj and on the Pane, Session, and Window pages that inherit
them. A reader cannot tell what a field reports without opening the
tmux man page and matching the token by name.

what:
- Add an Attributes section to Obj covering the server handle and
  every tmux format token it carries
- Describe client_mode_format from tmux's client mode default format,
  the one token the man page's FORMATS table omits
- Note in the summary that tmux reports each token as a string, and
  that None means the token was out of the listing's scope, absent
  from the running tmux, or expanded to empty
why: autodoc renders every dataclass field whether or not it is
described, so Pane's option scope, hook scope, and server fields
reach the API reference bare. A reader cannot tell which tmux flag
a scope selects, or what the server handle is used for, without
reading OptionsMixin and HooksMixin.

what:
- Add an Attributes section to Pane covering default_option_scope,
  default_hook_scope, and server
- Name the tmux flag each scope sends, and what an unset scope
  means for set-option, show-options, set-hook, and show-hooks
why: autodoc renders every dataclass field whether or not it is
described, so Window's option scope, hook scope, and server fields
reach the API reference bare. A reader cannot tell which tmux flag
a scope selects, or what the server handle is used for, without
reading OptionsMixin and HooksMixin.

what:
- Add an Attributes section to Window covering default_option_scope,
  default_hook_scope, and server
- Name the tmux flag each scope sends, and what an unset scope
  means for set-option, show-options, set-hook, and show-hooks
why: autodoc renders every dataclass field whether or not it is
described, so Session's option scope and hook scope fields reach the
API reference bare, and the server entry carries a type with no text.
Both scopes default to None, which reads as "no scope" rather than
the session scope tmux actually applies.

what:
- Add an Attributes section to Session covering default_option_scope
  and default_hook_scope
- Explain that an unset scope sends no flag, which tmux resolves as
  session scope, and that OptionScope.Session maps to the same
- Describe the server handle on the existing Parameters entry
why: The unreleased entry did not record that class fields now carry
descriptions where the API reference renders them.

what:
- Note the described fields under Documentation
@tony
tony force-pushed the attributes-backfill branch from 657e859 to 851e95f Compare July 26, 2026 01:22
@tony
tony merged commit 680224c into master Jul 26, 2026
15 checks passed
@tony
tony deleted the attributes-backfill branch July 26, 2026 10:22
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.

docs(api): dataclass fields without an Attributes section ship bare autodoc stubs

1 participant