Skip to content

Preview gp-sphinx#36 curated default-value rendering#668

Open
tony wants to merge 1 commit into
masterfrom
improved-defaults-reprs
Open

Preview gp-sphinx#36 curated default-value rendering#668
tony wants to merge 1 commit into
masterfrom
improved-defaults-reprs

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented May 9, 2026

Summary

  • Preview branch for git-pull/gp-sphinx#36, which curates parameter and data-attribute default-value rendering across the workspace. This PR pulls the gp-sphinx-family deps from that branch via [tool.uv.sources] so the docs build picks up the changes before a release bump propagates them via PyPI.
  • Empirical impact (libtmux): the audit drops from 171 ugly parameter defaults to 0. Method signatures like Pane._show_option(scope=<libtmux.constants._DefaultOptionScope object>, …) now render as Pane._show_option(scope=DEFAULT_OPTION_SCOPE, …) with DEFAULT_OPTION_SCOPE linked to the documented constant in the same <a class="reference internal"><code class="xref py py-class">…</code></a> HTML shape that inline :py:class: roles produce. Hook dataclass __init__ defaults stop showing =<factory> and instead render =[], ={}, =set(), etc.
  • Includes a [DO NOT MERGE] commit that adds the branch to .github/workflows/docs.yml's on.push.branches list so the live docs site previews the branch. Revert that commit before merging.

After gp-sphinx>=0.0.1a18 ships, replace this with a normal version bump (0.0.1a170.0.1a18 across the four pinned gp-sphinx-family packages) and revert both commits in this branch.

Test plan

  • uv lock resolves all gp-sphinx-family workspace siblings to commit 8c3a1418 on the branch
  • uv sync --all-extras --dev clean install from git sources
  • Local docs rebuild succeeds: cd docs && just html
  • Audit script confirms zero ugly parameter defaults: uv run python ../gp-sphinx/packages/sphinx-autodoc-typehints-gp/scripts/audit_defaults.py libtmux=docs/_build/html
  • Visual spot-check: Pane._show_option, Pane._show_hook, hook dataclass __init__ signatures
  • CI: docs workflow runs against this branch (enabled by the [DO NOT MERGE] commit) and publishes to the docs site for live preview

@codecov
Copy link
Copy Markdown

codecov Bot commented May 10, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.29%. Comparing base (5a34cc5) to head (898b0a9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #668   +/-   ##
=======================================
  Coverage   51.29%   51.29%           
=======================================
  Files          25       25           
  Lines        3488     3488           
  Branches      686      686           
=======================================
  Hits         1789     1789           
  Misses       1404     1404           
  Partials      295      295           

☔ View full report in Codecov by Sentry.
📢 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.

why: `DEFAULT_OPTION_SCOPE` is the sentinel default for the `scope=`
parameter on every option-related helper (Pane._show_option,
Server.show_options, Window._set_options_raw, …). Without a docstring
on the assignment Sphinx's autodoc skips it under
`automodule :members: undoc-members:`, so the docs site has no
`#libtmux.constants.DEFAULT_OPTION_SCOPE` anchor — and any default-
value cross-reference in those signatures has no target to link to.
Adding the attribute docstring (PEP 258 — module-attribute docstring
picked up by `ModuleAnalyzer.attr_docs`) gives the sentinel a docs
entry and lets the gp-sphinx default-value xref transform render
`scope=DEFAULT_OPTION_SCOPE` as a clickable link to the documented
constant on `api/libtmux.constants/`.

Also promote `_DefaultOptionScope`'s `# Sentinel value for default
scope` comment to a proper docstring; the class already shows up as
a documented entry on the constants page (per the autodoc default
options) and a real docstring describes the sentinel pattern more
clearly than the stub comment.

what:
- Add an attribute docstring to `DEFAULT_OPTION_SCOPE` describing the
  sentinel semantics and the per-receiver scope inference rule.
- Replace `_DefaultOptionScope`'s stub comment with a class
  docstring describing the sentinel-type role and pointing at the
  lone documented instance.
@tony tony force-pushed the improved-defaults-reprs branch from 367114a to 898b0a9 Compare May 30, 2026 12:14
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