feat(api-style): Add badge system for standard Python API entries#10
Merged
feat(api-style): Add badge system for standard Python API entries#10
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #10 +/- ##
==========================================
+ Coverage 88.82% 89.17% +0.35%
==========================================
Files 72 78 +6
Lines 7111 7576 +465
==========================================
+ Hits 6316 6756 +440
- Misses 795 820 +25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
3 tasks
c7b854e to
2755e95
Compare
why: Provide type and modifier badges for standard Python autodoc entries what: - Add _badges.py with badge group builder for type/modifier badges - Add _transforms.py with doctree-resolved handler and toolbar injection - Add _css.py with CSS class name constants - Add api_style.css with card containers, badge colors, responsive layout - Add __init__.py with Sphinx extension setup - Add pyproject.toml, README.md, py.typed
why: Verify badge building, modifier detection, and toolbar injection what: - Add tests for _CSS constants and obj_type helper - Add tests for build_badge_group (types, modifiers, tooltips, accessibility) - Add tests for _detect_modifiers and _detect_deprecated - Add tests for _inject_badges (toolbar, viewcode, headerlink handling) - Add tests for on_doctree_resolved event handler
why: Make the new package discoverable by uv, ruff, mypy, and pytest what: - Add workspace source and dev dependency - Add known-first-party and per-file-ignores for ruff - Add testpaths entry for pytest doctest collection - Update test_package_reference assertions for new package
why: Ensure the new package installs and imports correctly in CI what: - Add smoke_sphinx_autodoc_api_style function in package_tools.py - Add sphinx-autodoc-api-style to smoke test matrix in tests.yml
why: Showcase badge types, modifier badges, and card styling with live examples what: - Add gas_demo_api.py with synthetic objects exercising every badge - Add sphinx-autodoc-api-style.md package page with badge reference - Wire extension into docs/conf.py - Update package index and redirects
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.
Summary
gp_sphinx.api_styleSphinx extension that injects type and modifier badges into standard Python domain entries (functions, classes, methods, properties, attributes, data, exceptions)gas-prefix, 8 distinct type colors (function=blue, class=indigo, method=cyan, property=teal, attribute=slate, data=grey, exception=rose, type=violet), light/dark mode, Furo integrationsphinx-autodoc-pytest-fixtures(spf-prefix) so API pages and fixture pages look consistentArchitecture
Pure doctree transform — hooks into
doctree-resolved, walksaddnodes.descnodes, detects modifiers fromdesc_sig_keywordnodes and deprecation fromversionmodified, injects badge groups. No directive or documenter overrides, so cross-references and object IDs are preserved.Badge types
function,class,method,property,attribute,data,exceptiondesc.objtypeasyncdesc_sig_keyword("async")classmethoddesc_sig_keyword("classmethod")staticmethoddesc_sig_keyword("static")abstractdesc_sig_keyword("abstractmethod")finaldesc_sig_keyword("final")deprecatedversionmodified(type='deprecated')Files
Extension (
packages/gp-sphinx/src/gp_sphinx/api_style/):__init__.py—setup(), CSS registration, abbreviation visitor_css.py— CSS class constants (gas-*prefix)_badges.py— Badge group builder with canonical ordering_transforms.py— Doctree-resolved handler, modifier/deprecated detection_static/css/api_style.css— Full CSS token system, light/dark, Furo integrationTests (
tests/ext/api_style/): 37 unit tests + 11 doctestsDocs (
docs/packages/api-styling.md): Live demo page with synthetic API moduleBugfixes included
desctraversal so methods get their ownobjtype(not parent class)descnodes (class doesn't inherit method's deprecation)docs/_ext/package_reference.pyTest plan
uv run ruff check . --fix --show-fixes— all checks passeduv run ruff format .— no changesuv run mypy src tests— no issues in 33 source filesuv run pytest --reruns 0— 711 passed, 3 skippeduv run sphinx-build -b html docs docs/_build/html— build succeeded