MCPcopy
hub / github.com/pydata/xarray / collapsible_section

Function collapsible_section

xarray/core/formatting_html.py:180–205  ·  view source on GitHub ↗
(
    header: str,
    inline_details="",
    details="",
    n_items=None,
    enabled=True,
    collapsed=False,
    span_grid=False,
)

Source from the content-addressed store, hash-verified

178
179
180def collapsible_section(
181 header: str,
182 inline_details="",
183 details="",
184 n_items=None,
185 enabled=True,
186 collapsed=False,
187 span_grid=False,
188) -> str:
189 # "unique" id to expand/collapse the section
190 data_id = "section-" + str(uuid.uuid4())
191
192 has_items = n_items is not None and n_items
193 n_items_span = "" if n_items is None else f" <span>({n_items})</span>"
194 enabled_attr = "" if enabled and has_items else " disabled"
195 collapsed_attr = "" if collapsed or not has_items else " checked"
196 span_grid_attr = " xr-span-grid" if span_grid else ""
197 tip = " title='Expand/collapse section'" if enabled_attr == "" else ""
198 html = (
199 f"<input id='{data_id}' class='xr-section-summary-in' type='checkbox'{enabled_attr}{collapsed_attr} />"
200 f"<label for='{data_id}' class='xr-section-summary{span_grid_attr}'{tip}>{header}{n_items_span}</label>"
201 f"<div class='xr-section-inline-details'>{inline_details}</div>"
202 )
203 if details:
204 html += f"<div class='xr-section-details'>{details}</div>"
205 return html
206
207
208def _mapping_section(

Callers 3

_mapping_sectionFunction · 0.85
dim_sectionFunction · 0.85
_build_datatree_displaysFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…