Skip to content

Add sphinx-autodoc-pytest-fixtures package#6

Merged
tony merged 5 commits intomainfrom
init-3
Apr 3, 2026
Merged

Add sphinx-autodoc-pytest-fixtures package#6
tony merged 5 commits intomainfrom
init-3

Conversation

@tony
Copy link
Copy Markdown
Member

@tony tony commented Apr 3, 2026

Summary

  • Extract sphinx_pytest_fixtures from libtmux into a new workspace package
  • Rename to sphinx-autodoc-pytest-fixtures (follows sphinx-autodoc-* convention)
  • Badge CSS: use dotted underline for abbr tooltip affordance

Test plan

  • 548 tests pass (72 new unit tests + 54 integration tests)
  • mypy clean
  • ruff clean

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 3, 2026

Codecov Report

❌ Patch coverage is 92.40622% with 166 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.37%. Comparing base (75dfae5) to head (383b35d).

Files with missing lines Patch % Lines
...ext/pytest_fixtures/test_sphinx_pytest_fixtures.py 90.23% 54 Missing ⚠️
.../src/sphinx_autodoc_pytest_fixtures/_transforms.py 81.29% 26 Missing ⚠️
.../src/sphinx_autodoc_pytest_fixtures/_documenter.py 80.18% 22 Missing ⚠️
...s/src/sphinx_autodoc_pytest_fixtures/_detection.py 82.35% 18 Missing ⚠️
...tures/src/sphinx_autodoc_pytest_fixtures/_index.py 89.83% 12 Missing ⚠️
...es/src/sphinx_autodoc_pytest_fixtures/_metadata.py 91.91% 11 Missing ⚠️
...tures/src/sphinx_autodoc_pytest_fixtures/_store.py 88.23% 10 Missing ⚠️
.../src/sphinx_autodoc_pytest_fixtures/_directives.py 95.56% 9 Missing ⚠️
...ixtures/test_sphinx_pytest_fixtures_integration.py 99.61% 2 Missing ⚠️
...ures/src/sphinx_autodoc_pytest_fixtures/_models.py 98.57% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main       #6      +/-   ##
==========================================
+ Coverage   87.49%   89.37%   +1.88%     
==========================================
  Files          35       50      +15     
  Lines        3518     5704    +2186     
==========================================
+ Hits         3078     5098    +2020     
- Misses        440      606     +166     

☔ 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.

@tony
Copy link
Copy Markdown
Member Author

tony commented Apr 3, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

6 issues were identified by review agents but all scored below the confidence threshold (80):

  • Missing NullHandler in __init__.py (75) — CLAUDE.md requires it for library packages, but this __init__.py has no logger defined; it only re-exports from submodules that use sphinx.util.logging
  • Version/classifier mismatch: 0.0.1a0 alpha with Development Status :: 4 - Beta (75) — packaging metadata issue, matches the pattern used by other workspace packages
  • Blanket "D" ruff suppression (75) — same pattern removed from sphinx-argparse-neo in commit 89faf49, but justified here as a verbatim copy not yet cleaned to project standards
  • CSS comment describes dotted underline as "unwanted" but code intentionally applies it (25) — comment describes the pre-fix Normalize.css problem, not the current intent
  • ignore_errors = true mypy override vs targeted disable_error_code (50) — blunter than sphinx_fonts pattern, but appropriate for a verbatim copy
  • Deferred stdlib imports in function bodies (25) — CLAUDE.md addresses import style, not location; deferred imports are a valid Python pattern

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

@tony
Copy link
Copy Markdown
Member Author

tony commented Apr 3, 2026

Code review

Found 1 issue:

  1. CSS file header comment still references the old package name sphinx_pytest_fixtures instead of sphinx_autodoc_pytest_fixtures — stale after the rename in commit 070ded6

/* ── sphinx_pytest_fixtures ────────────────────────────────
* Multi-badge group: scope + kind/state + FIXTURE
* Three slots, hard ceiling: at most 3 badges per fixture.

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

tony added 2 commits April 3, 2026 15:12
Sphinx extension that documents pytest fixtures as first-class domain
objects. Registers py:fixture as a directive/role and provides three
autodoc-style directives:

- autofixture:: — document a single fixture with full metadata
- autofixtures:: — discover and document all fixtures in a module
- autofixture-index:: — summary table with badge columns

Each fixture renders with scope badges (session/module/class), kind
badges (factory/override_hook), autouse indicators, classified
dependency lists, auto-generated usage snippets, and reverse-dependency
("Used by") sections. Dependencies are classified as project fixtures
(internal xrefs), pytest builtins (external links to pytest docs), or
unresolved.

why: pytest fixtures are central to test structure but were previously
documented as plain function signatures with no special handling for
scope, autouse, dependencies, or fixture-specific patterns.
what:
- Frozen dataclasses (FixtureMeta, FixtureDep) for pickle-safe Sphinx
  build environment storage across incremental builds
- Parallel-safe (parallel_read_safe + parallel_write_safe) with
  explicit store rebuild on env-merge-info and env-purge-doc
- Badge accessibility: WCAG AA contrast ratios, <abbr> with tabindex
  for keyboard/touch tooltip access
- Forward-ref resolution via AST introspection of TYPE_CHECKING blocks
- Handles pytest 9+ FixtureFunctionDefinition and older marker style
- Validation codes SPF001-SPF006 with configurable lint level
…ixtures

Unit tests exercise each subsystem in isolation: fixture detection and
classification (_is_pytest_fixture, _is_factory), dependency filtering
and classification (_get_user_deps, _classify_deps), return type
extraction with Generator unwrapping, badge node rendering, store
version guards, public-to-canonical name resolution, parallel merge
handling, usage snippet generation, and validation codes SPF001-SPF006.

Integration tests run full Sphinx HTML builds with synthetic fixture
modules and assert on rendered output: domain registration, cross-ref
resolution via :fixture: role, badge CSS classes in HTML, scope
lifecycle callouts, factory/override_hook usage snippets, "Used by"
reverse-dep links, autofixture-index table rendering, and build
warning behavior at each lint level.

why: The extension has complex interactions between autodoc, the Python
domain, and Sphinx's incremental build environment — each subsystem
needs isolated verification, and end-to-end builds catch integration
issues that unit tests miss.
what:
- Synthetic fixture modules (not libtmux-dependent) for reproducible
  integration tests across environments
- HAS_LIBTMUX guard for 3 forward-ref resolution tests that need real
  libtmux fixtures with TYPE_CHECKING imports
- _SphinxResult namedtuple wrapping app/srcdir/outdir/status/warnings
  for clean assertion patterns in integration tests
@tony
Copy link
Copy Markdown
Member Author

tony commented Apr 3, 2026

Code review

Found 2 issues:

  1. Duplicate CSS class on pages with multiple deprecated fixtures — transform_content() walks all desc nodes in the document and appends _CSS.DEPRECATED without checking if already present. Each deprecated fixture's transform_content() re-appends to every already-matched parent, producing class="spf-deprecated spf-deprecated ..." in the HTML.

# Add spf-deprecated class to the parent desc node for CSS muting
for parent in self.state.document.findall(addnodes.desc):
for sig in parent.findall(addnodes.desc_signature):
if sig.get("spf_deprecated"):
parent["classes"].append(_CSS.DEPRECATED)
break

  1. mypy override comment says "verbatim copy from libtmux" but the dependency direction is reversed — libtmux consumes this package from gp-sphinx, this package is the origin. The comment should describe the actual reason for ignore_errors = true.

gp-sphinx/pyproject.toml

Lines 72 to 75 in 484f568

[[tool.mypy.overrides]]
# sphinx_autodoc_pytest_fixtures is a verbatim copy from libtmux, not yet typed strictly.
module = ["sphinx_autodoc_pytest_fixtures", "sphinx_autodoc_pytest_fixtures.*", "tests.ext.pytest_fixtures.*"]
ignore_errors = true

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

tony added 3 commits April 3, 2026 16:07
why: The package needs workspace membership, dependency wiring, and
tool configuration to be discoverable by uv, ruff, mypy, and pytest.
what:
- Add workspace source and dev dependency
- ruff: add to known-first-party; suppress D417 only (numpy convention
  already handles D413/D211/D213)
- mypy: ignore_errors for gradual typing adoption
- pytest: register "integration" marker for Sphinx build tests;
  add --ignore so doctest-modules skips the package
why: The dotted underline signals that badges have tooltip text on
hover, matching the browser convention for abbr[title] elements.
what:
- Change text-decoration from none to underline dotted on abbr.spf-badge
…i-fixture pages

why: transform_content() walks all desc nodes in the document and
appends spf-deprecated without checking if already present. On a page
with multiple deprecated fixtures, each call re-appends to every
already-matched parent.
what:
- Add membership check before appending _CSS.DEPRECATED to parent classes
@tony tony merged commit 49772c1 into main Apr 3, 2026
24 checks passed
@tony tony deleted the init-3 branch April 3, 2026 21:30
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