From 4dc1f62b1b03cb82674cb23341120f9915214d05 Mon Sep 17 00:00:00 2001 From: Daniel McCloy Date: Tue, 13 Aug 2024 14:16:38 -0500 Subject: [PATCH 1/8] make it look good in website docs --- doc/_static/style.css | 24 ++- .../repr/_acquisition.html.jinja | 34 ++-- mne/html_templates/repr/_channels.html.jinja | 22 +-- mne/html_templates/repr/_filters.html.jinja | 20 +-- mne/html_templates/repr/_general.html.jinja | 24 +-- mne/html_templates/repr/epochs.html.jinja | 2 +- mne/html_templates/repr/evoked.html.jinja | 2 +- mne/html_templates/repr/forward.html.jinja | 6 +- mne/html_templates/repr/ica.html.jinja | 2 +- mne/html_templates/repr/info.html.jinja | 2 +- .../repr/inverse_operator.html.jinja | 2 +- mne/html_templates/repr/raw.html.jinja | 2 +- mne/html_templates/repr/spectrum.html.jinja | 2 +- .../repr/static/_toggle.html.jinja | 8 + mne/html_templates/repr/static/repr.css | 152 ++++++------------ mne/html_templates/repr/static/repr.js | 46 ++---- mne/html_templates/repr/tfr.html.jinja | 2 +- 17 files changed, 133 insertions(+), 219 deletions(-) create mode 100644 mne/html_templates/repr/static/_toggle.html.jinja diff --git a/doc/_static/style.css b/doc/_static/style.css index 4bc6e03708e..caf054684ea 100644 --- a/doc/_static/style.css +++ b/doc/_static/style.css @@ -161,17 +161,25 @@ iframe.sg_report { top: 0; } -/* TODO: Either pydata-sphinx-theme (for using Bootstrap) or sphinx-gallery (for adding table formatting) should fix this */ -.table-striped-columns>:not(caption)>tr>:nth-child(2n),.table-striped>tbody>tr:nth-of-type(odd)>* { - --bs-table-accent-bg: var(--bs-table-striped-bg); +/* ******************************************************** HTML repr tables */ + +/* make table responsive to pydata-sphinx-theme's light/dark mode */ +.table > :not(caption) > * > * { color: var(--pst-color-text-base); } -.table-hover>tbody>tr:hover>* { - --bs-table-accent-bg: var(--bs-table-hover-bg); - color: var(--pst-color-text-base); +.mne-repr-table tbody tr:hover { + background-color: var(--pst-color-table-row-hover-bg); } -.rendered_html table { - color: var(--pst-color-text-base); +.mne-repr-section-toggle > button > svg > path { + fill: var(--pst-color-text-base); +} +/* +make section header rows more distinct (and harmonize with pydata-sphinx-theme table +style in the process). Color copied from pydata-sphinx-theme; 2px copied from bootstrap. +*/ +.mne-repr-table th { + padding-top: 1rem; + border-bottom: 2px solid var(--pst-color-primary); } diff --git a/mne/html_templates/repr/_acquisition.html.jinja b/mne/html_templates/repr/_acquisition.html.jinja index c688107b0d1..16193d75ac3 100644 --- a/mne/html_templates/repr/_acquisition.html.jinja +++ b/mne/html_templates/repr/_acquisition.html.jinja @@ -3,33 +3,25 @@ {# Collapse content during documentation build. #} {% if collapsed %} -{% set collapsed_row_class = "repr-element-faded repr-element-collapsed" %} +{% set collapsed_row_class = "mne-repr-collapsed" %} {% else %} {% set collapsed_row_class = "" %} {% endif %} - - - - - - {{ section }} - + {%include 'static/_toggle.html.jinja' %} {% if duration %} - + Duration {{ duration }} (HH:MM:SS) {% endif %} {% if inst is defined and inst | has_attr("kind") and inst | has_attr("nave") %} - + Aggregation {% if inst.kind == "average" %} average of {{ inst.nave }} epochs @@ -42,21 +34,21 @@ {% endif %} {% if inst is defined and inst | has_attr("comment") %} - + Condition {{inst.comment}} {% endif %} {% if inst is defined and inst | has_attr("events") %} - + Total number of events {{ inst.events | length }} {% endif %} {% if event_counts is defined %} - + Events counts {% if events is not none %} @@ -72,35 +64,35 @@ {% endif %} {% if inst is defined and inst | has_attr("tmin") and inst | has_attr("tmax") %} - + Time range {{ inst | format_time_range }} {% endif %} {% if inst is defined and inst | has_attr("baseline") %} - + Baseline {{ inst | format_baseline }} {% endif %} {% if info["sfreq"] is defined and info["sfreq"] is not none %} - + Sampling frequency {{ "%0.2f" | format(info["sfreq"]) }} Hz {% endif %} {% if inst is defined and inst.times is defined %} - + Time points {{ inst.times | length | format_number }} {% endif %} {% if inst is defined and inst | has_attr("metadata") %} - + Metadata {{ inst | format_metadata }} diff --git a/mne/html_templates/repr/_channels.html.jinja b/mne/html_templates/repr/_channels.html.jinja index d6ccb09312d..63ddc1f8829 100644 --- a/mne/html_templates/repr/_channels.html.jinja +++ b/mne/html_templates/repr/_channels.html.jinja @@ -3,36 +3,28 @@ {# Collapse content during documentation build. #} {% if collapsed %} -{% set collapsed_row_class = "repr-element-faded repr-element-collapsed" %} +{% set collapsed_row_class = "mne-repr-collapsed" %} {% else %} {% set collapsed_row_class = "" %} {% endif %} - - - - - - {{ section }} - + {%include 'static/_toggle.html.jinja' %} {% for channel_type, channels in (info | format_channels).items() %} {% set channel_names_good = channels["good"] | map(attribute='name_html') | join(', ') %} - + {{ channel_type }} - {% if channels["bad"] %} {% set channel_names_bad = channels["bad"] | map(attribute='name_html') | join(', ') %} - and {% endif %} @@ -41,7 +33,7 @@ {% endfor %} - + Head & sensor digitization {% if info["dig"] is not none %} {{ info["dig"] | length }} points diff --git a/mne/html_templates/repr/_filters.html.jinja b/mne/html_templates/repr/_filters.html.jinja index b01841cf137..384ec31bda0 100644 --- a/mne/html_templates/repr/_filters.html.jinja +++ b/mne/html_templates/repr/_filters.html.jinja @@ -3,40 +3,32 @@ {# Collapse content during documentation build. #} {% if collapsed %} -{% set collapsed_row_class = "repr-element-faded repr-element-collapsed" %} +{% set collapsed_row_class = "mne-repr-collapsed" %} {% else %} {% set collapsed_row_class = "" %} {% endif %} - - - - - - {{ section }} - + {%include 'static/_toggle.html.jinja' %} {% if info["highpass"] is defined and info["highpass"] is not none %} - + Highpass {{ "%0.2f" | format(info["highpass"]) }} Hz {% endif %} {% if info["lowpass"] is defined and info["lowpass"] is not none %} - + Lowpass {{ "%0.2f" | format(info["lowpass"]) }} Hz {% endif %} {% if info.projs is defined and info.projs %} - + Projections {% for p in (info | format_projs) %} diff --git a/mne/html_templates/repr/_general.html.jinja b/mne/html_templates/repr/_general.html.jinja index c9ad8310e64..4b56619e3d2 100644 --- a/mne/html_templates/repr/_general.html.jinja +++ b/mne/html_templates/repr/_general.html.jinja @@ -3,26 +3,18 @@ {# Collapse content during documentation build. #} {% if collapsed %} -{% set collapsed_row_class = "repr-element-faded repr-element-collapsed" %} +{% set collapsed_row_class = "mne-repr-collapsed" %} {% else %} {% set collapsed_row_class = "" %} {% endif %} - - - - - - {{ section }} - + {%include 'static/_toggle.html.jinja' %} {% if filenames %} - + Filename(s) {% for f in filenames %} @@ -33,12 +25,12 @@ {% endif %} - + MNE object type {{ inst | data_type }} - + Measurement date {% if info["meas_date"] is defined and info["meas_date"] is not none %} {{ info["meas_date"] | dt_to_str }} @@ -47,7 +39,7 @@ {% endif %} - + Participant {% if info["subject_info"] is defined and info["subject_info"] is not none %} {% if info["subject_info"]["his_id"] is defined %} @@ -58,7 +50,7 @@ {% endif %} - + Experimenter {% if info["experimenter"] is defined and info["experimenter"] is not none %} {{ info["experimenter"] }} diff --git a/mne/html_templates/repr/epochs.html.jinja b/mne/html_templates/repr/epochs.html.jinja index 991aa8de0e3..6b33c177e87 100644 --- a/mne/html_templates/repr/epochs.html.jinja +++ b/mne/html_templates/repr/epochs.html.jinja @@ -2,7 +2,7 @@ {% set info = inst.info %} - +
{%include '_general.html.jinja' %} {%include '_acquisition.html.jinja' %} {%include '_channels.html.jinja' %} diff --git a/mne/html_templates/repr/evoked.html.jinja b/mne/html_templates/repr/evoked.html.jinja index 991aa8de0e3..6b33c177e87 100644 --- a/mne/html_templates/repr/evoked.html.jinja +++ b/mne/html_templates/repr/evoked.html.jinja @@ -2,7 +2,7 @@ {% set info = inst.info %} -
+
{%include '_general.html.jinja' %} {%include '_acquisition.html.jinja' %} {%include '_channels.html.jinja' %} diff --git a/mne/html_templates/repr/forward.html.jinja b/mne/html_templates/repr/forward.html.jinja index 22be9248ecc..510a775c2b6 100644 --- a/mne/html_templates/repr/forward.html.jinja +++ b/mne/html_templates/repr/forward.html.jinja @@ -1,12 +1,12 @@ {%include '_js_and_css.html.jinja' %} -
+
{% for channel_type, channels in (info | format_channels).items() %} {% set channel_names_good = channels["good"] | map(attribute='name_html') | join(', ') %}
{{ channel_type }} -