sphinx-filter-tabs 0.6.0__py3-none-any.whl → 0.7.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
filter_tabs/extension.py CHANGED
@@ -117,6 +117,7 @@ class FilterTabsRenderer:
117
117
  legend += nodes.Text(f"Filter by: {', '.join(self.tab_names)}")
118
118
  fieldset += legend
119
119
 
120
+ # --- Backward-compatible CSS Handling ---
120
121
  # Generate the dynamic CSS that handles the core filtering logic.
121
122
  css_rules = []
122
123
  for tab_name in self.tab_names:
@@ -127,21 +128,33 @@ class FilterTabsRenderer:
127
128
  f".{SFT_TAB_BAR}:has(#{radio_id}:checked) ~ "
128
129
  f".{SFT_CONTENT} > .{SFT_PANEL}[data-filter='{tab_name}'] {{ display: block; }}"
129
130
  )
130
- # Embed the generated CSS directly into the HTML.
131
- style_node = nodes.raw(text=f"<style>{''.join(css_rules)}</style>", format="html")
132
131
 
133
- # Create the tab bar with radio inputs and labels.
134
- tab_bar = nodes.container(classes=[SFT_TAB_BAR], role='tablist')
132
+ # 1. Write the dynamic CSS to a temporary file in the build's static directory.
133
+ css_content = ''.join(css_rules)
134
+ static_dir = Path(self.env.app.outdir) / '_static'
135
+ static_dir.mkdir(parents=True, exist_ok=True)
136
+ css_filename = f"dynamic-filter-tabs-{group_id}.css"
137
+ (static_dir / css_filename).write_text(css_content, encoding='utf-8')
138
+
139
+ # 2. Add the temporary CSS file using the backward-compatible app.add_css_file() method.
140
+ # This correctly places a <link> tag in the HTML <head>.
141
+ self.env.app.add_css_file(css_filename)
142
+
143
+ # Create the tab bar, but without the role="tablist"
144
+ # Screen Reader Ambiguity: Elements announced as group of radio buttons
145
+ tab_bar = nodes.container(classes=[SFT_TAB_BAR])
135
146
  for tab_name in self.tab_names:
136
147
  radio_id = f"{group_id}-{self._css_escape(tab_name)}"
137
- # The radio buttons are functionally necessary but visually hidden.
148
+
149
+ # Create the radio input, but without the role="tab"
138
150
  radio = RadioInputNode(type='radio', name=group_id, ids=[radio_id])
151
+
139
152
  if tab_name == self.default_tab:
140
- radio['checked'] = 'checked' # Set the default tab.
153
+ radio['checked'] = 'checked'
141
154
  tab_bar += radio
142
155
 
143
- # The labels are the visible, clickable tabs.
144
- label = LabelNode(for_id=radio_id, role='tab')
156
+ # The label correctly points to the radio input
157
+ label = LabelNode(for_id=radio_id)
145
158
  label += nodes.Text(tab_name)
146
159
  tab_bar += label
147
160
  fieldset += tab_bar
@@ -163,8 +176,8 @@ class FilterTabsRenderer:
163
176
  fieldset += content_area
164
177
  container.children = [fieldset]
165
178
 
166
- # The final structure is the dynamic style block followed by the main container.
167
- return [style_node, container]
179
+ # Return just the main container node. Sphinx handles adding the CSS file to the <head>.
180
+ return [container]
168
181
 
169
182
  def render_fallback(self) -> list[nodes.Node]:
170
183
  """Renders content as a series of simple admonitions for non-HTML builders (e.g., LaTeX/PDF)."""
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sphinx-filter-tabs
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: A Sphinx extension for accessible, JS-free filterable content tabs.
5
5
  Author-email: Aputsiak Niels Janussen <aputsiak+sphinx@gmail.com>
6
6
  License: GNU General Public License v3.0
@@ -0,0 +1,9 @@
1
+ filter_tabs/__init__.py,sha256=VPpIhj4HaLeMX7ai7dZFkUm81ii2ePPGjCd9hsMjsN4,397
2
+ filter_tabs/extension.py,sha256=tU2ZBYWRmYHyvQh8NgPWWqFidunsL16KHhoyqMfboCw,20739
3
+ filter_tabs/static/filter_tabs.css,sha256=btJoI-Q87e0XUQARwJUhM6RCfg5m2dvxKtfABZ2zRsc,3429
4
+ sphinx_filter_tabs-0.7.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
+ sphinx_filter_tabs-0.7.0.dist-info/METADATA,sha256=WJjRU9rRRzgFFKlheXL4QTa_c1vF0FWhd3bqMyiG_zA,2264
6
+ sphinx_filter_tabs-0.7.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
+ sphinx_filter_tabs-0.7.0.dist-info/entry_points.txt,sha256=za_bQcueY8AHyq7XnnjkW9X3C-LsZjeERVQ_ds7jV1A,62
8
+ sphinx_filter_tabs-0.7.0.dist-info/top_level.txt,sha256=K0Iy-6EsYYdvlyXdsJT0SQg-BLDBgT5-Y8ZKy5SNAfc,12
9
+ sphinx_filter_tabs-0.7.0.dist-info/RECORD,,
@@ -1,9 +0,0 @@
1
- filter_tabs/__init__.py,sha256=VPpIhj4HaLeMX7ai7dZFkUm81ii2ePPGjCd9hsMjsN4,397
2
- filter_tabs/extension.py,sha256=ZWq-MCft-RvZtx4xzVyDGXGGtgddh8dZdeHTivIcN34,20204
3
- filter_tabs/static/filter_tabs.css,sha256=btJoI-Q87e0XUQARwJUhM6RCfg5m2dvxKtfABZ2zRsc,3429
4
- sphinx_filter_tabs-0.6.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
5
- sphinx_filter_tabs-0.6.0.dist-info/METADATA,sha256=msO5UEdrQPPLpUF3d0aRI-HaO9gqLccVfTbw3bMGtVQ,2264
6
- sphinx_filter_tabs-0.6.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
7
- sphinx_filter_tabs-0.6.0.dist-info/entry_points.txt,sha256=za_bQcueY8AHyq7XnnjkW9X3C-LsZjeERVQ_ds7jV1A,62
8
- sphinx_filter_tabs-0.6.0.dist-info/top_level.txt,sha256=K0Iy-6EsYYdvlyXdsJT0SQg-BLDBgT5-Y8ZKy5SNAfc,12
9
- sphinx_filter_tabs-0.6.0.dist-info/RECORD,,