A Sphinx extension for accessible, CSS-first filterable content tabs.
Project description
Sphinx Filter Tabs Extension
A robust Sphinx extension for creating accessible, filterable content tabs using pure CSS and semantic HTML.
📖 View extension and documentation at: https://aputtu.github.io/sphinx-filter-tabs/
This extension provides filter-tabs and tab directives to create user-friendly, switchable content blocks. Perfect for showing code examples in multiple languages, installation instructions for different platforms, or any content that benefits from organized, filterable presentation.
Key Features
- Pure CSS Implementation: Zero JavaScript dependencies for maximum compatibility and performance
- Fully Accessible: WAI-ARIA compliant with native keyboard navigation and screen reader support
- Semantic HTML: Uses standard form controls (radio buttons) for robust, predictable behavior
- Universal Compatibility: Works in all environments where CSS is supported, including strict CSP policies
- Easy Customization: Theme colors and styling through simple CSS custom properties
- Multiple Output Formats: Graceful fallback to sequential content in PDF/LaTeX builds
- Proven Reliability: Comprehensive test suite across multiple Python and Sphinx versions
Quick Start
Installation
pip install sphinx-filter-tabs
Enable the Extension
Add to your conf.py:
extensions = [
# ... your other extensions ...
'filter_tabs.extension',
]
Basic Usage
.. filter-tabs::
This content appears above all tabs.
.. tab:: Python
Install using pip:
.. code-block:: bash
pip install my-package
.. tab:: Conda (default)
Install using conda:
.. code-block:: bash
conda install my-package
.. tab:: From Source
Build from source:
.. code-block:: bash
git clone https://github.com/user/repo.git
cd repo
pip install -e .
Configuration Options
Add these optional settings to your conf.py:
# Customize the active tab highlight color
filter_tabs_highlight_color = '#007bff' # Default: '#007bff'
# Enable debug logging during development
filter_tabs_debug_mode = False # Default: False
Advanced Usage
Custom Legend
Override the auto-generated legend:
.. filter-tabs::
:legend: Select Your Installation Method
.. tab:: Quick Install
Content here...
ARIA Labels for Accessibility
Provide descriptive labels for screen readers:
.. filter-tabs::
.. tab:: CLI
:aria-label: Command line installation instructions
Content for command line users...
Nested Tabs
Create complex layouts with nested tab groups:
.. filter-tabs::
.. tab:: Windows
Choose your package manager:
.. filter-tabs::
.. tab:: Chocolatey
choco install my-package
.. tab:: Scoop
scoop install my-package
How It Works
This extension uses a pure CSS architecture with semantic HTML:
- Radio buttons provide the selection mechanism (hidden but accessible)
- CSS
:checkedselectors control panel visibility - Fieldset/legend structure provides semantic grouping
- ARIA attributes enhance screen reader support
- Native keyboard navigation works through standard form controls
This approach ensures:
- Maximum compatibility across all browsers and assistive technologies
- Better performance with no JavaScript parsing or execution
- Enhanced security for environments with strict Content Security Policies
- Simplified maintenance with fewer dependencies and potential conflicts
Browser Support
Works in all modern browsers that support:
- CSS3 selectors (
:checked, attribute selectors) - Basic ARIA attributes
- HTML5 form elements
This includes all browsers from the last 10+ years.
Development
Quick Setup
git clone https://github.com/aputtu/sphinx-filter-tabs.git
cd sphinx-filter-tabs
./scripts/setup_dev.sh
This creates a virtual environment and builds the documentation.
Development Commands
# Activate virtual environment
source venv/bin/activate
# Run tests
pytest
# Build documentation
./scripts/dev.sh html
# Run tests across multiple Sphinx versions
tox
# Clean build and start fresh
./scripts/dev.sh clean-all
# Export project structure for analysis
./scripts/export-project.sh
Testing
The project includes comprehensive tests covering:
- Basic tab functionality and content visibility
- Accessibility features and ARIA compliance
- Nested tabs and complex layouts
- Multiple output formats (HTML, LaTeX)
- Cross-browser compatibility
Tests run automatically on:
- Python versions 3.10, 3.12
- Sphinx versions 7.0, 7.4, 8.0, 8.2, 9.0, 9.1
- Multiple operating systems via GitHub Actions
Architecture
The extension consists of three main components:
extension.py- Sphinx integration, directives, and node definitionsrenderer.py- HTML generation and output formattingstatic/filter_tabs.css- Pure CSS styling and functionality
This clean separation makes the code easy to understand, test, and maintain.
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass:
pytest - Submit a pull request
License
GNU General Public License v3.0. See LICENSE for details.
Changelog
See CHANGELOG.md for version history and migration notes.
Support
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_filter_tabs-1.3.1.tar.gz.
File metadata
- Download URL: sphinx_filter_tabs-1.3.1.tar.gz
- Upload date:
- Size: 33.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4f57e52fb739cd2880ab5faeb1be477627243b811bcb2df18b38b01954c2e1bd
|
|
| MD5 |
7a8e4e42e0e18a79884976d00d9fe369
|
|
| BLAKE2b-256 |
2b43136c3a7878363f37eff04ff6af5d3f5180555f0dab4e3136f8a0d1f8ccca
|
Provenance
The following attestation bundles were made for sphinx_filter_tabs-1.3.1.tar.gz:
Publisher:
test.yml on aputtu/sphinx-filter-tabs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_filter_tabs-1.3.1.tar.gz -
Subject digest:
4f57e52fb739cd2880ab5faeb1be477627243b811bcb2df18b38b01954c2e1bd - Sigstore transparency entry: 969338013
- Sigstore integration time:
-
Permalink:
aputtu/sphinx-filter-tabs@58b6ce632fafe73a910402a769b27a2859046c0c -
Branch / Tag:
refs/tags/v1.3.1 - Owner: https://github.com/aputtu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@58b6ce632fafe73a910402a769b27a2859046c0c -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_filter_tabs-1.3.1-py3-none-any.whl.
File metadata
- Download URL: sphinx_filter_tabs-1.3.1-py3-none-any.whl
- Upload date:
- Size: 29.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
27275c9ffba3c501a914e81bbfc57c3143b74c451be6a35edd852e73fcb272b9
|
|
| MD5 |
a8816fe066a66846da4cf9b360ecf6f5
|
|
| BLAKE2b-256 |
bcbdf6dad427214e46de135ca12fe50a9abc49b9493c36337ee2ef64bd5358a4
|
Provenance
The following attestation bundles were made for sphinx_filter_tabs-1.3.1-py3-none-any.whl:
Publisher:
test.yml on aputtu/sphinx-filter-tabs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_filter_tabs-1.3.1-py3-none-any.whl -
Subject digest:
27275c9ffba3c501a914e81bbfc57c3143b74c451be6a35edd852e73fcb272b9 - Sigstore transparency entry: 969338015
- Sigstore integration time:
-
Permalink:
aputtu/sphinx-filter-tabs@58b6ce632fafe73a910402a769b27a2859046c0c -
Branch / Tag:
refs/tags/v1.3.1 - Owner: https://github.com/aputtu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@58b6ce632fafe73a910402a769b27a2859046c0c -
Trigger Event:
push
-
Statement type: