You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add alt_text, alt_title, and is_decorative to BaseShape (a11y phase 1) (#31)
Implements the first slice of issue #22 (Accessibility epic). All shapes
deriving from BaseShape (autoshapes, group shapes, graphic frames,
connectors, pictures) now expose three properties screen readers and
accessibility checkers depend on:
• shape.alt_text — alternative text description (cNvPr/@Descr)
• shape.alt_title — alt-text title (cNvPr/@title)
• shape.is_decorative — Office 2019+ decorative flag suppressing the
shape from screen-reader output
Surface lives on BaseShape so every concrete shape type inherits it
without duplication. alt_text and alt_title are independent attributes
on <p:cNvPr> and round-trip cleanly. is_decorative is the Office 2019+
extension element <adec:decorative val="1"/> nested inside
<a:extLst>/<a:ext uri="{FF2B5EF4-FFF2-40B4-BE49-F238E27FC236}">; the
extension is added on True, removed entirely on False so unaffected
shapes serialize identically.
Setters accept None and empty string to clear, matching python-pptx
convention. Getters return empty string when the attribute is absent
rather than None, mirroring shape.name.
Out of scope (deferred to follow-up PRs):
• slide.accessibility_issues audit method
• Reading-order surface
• PictureFormat.alt_text shortcut convenience
Tests: 37 new unit tests in tests/shapes/test_base.py covering get/set,
None and empty-string handling, round-trip XML stability, independence
of alt_text vs alt_title, and the decorative extension structure.
Verification:
pytest tests/ → 3054 passed (was 3017; +37 new)
behave features/ → 981 scenarios passed, 0 failed
ruff check → All checks passed
ruff format → 201 files already formatted
Refs #22
Co-authored-by: Matthew Horoszowski <mhoroszowski@Winton.lan>
0 commit comments