mirror of
https://github.com/pacnpal/django-anymail.git
synced 2025-12-20 03:41:05 -05:00
Docs: simplify editing ESP feature matrix
Move the big ESP feature matrix table into a CSV file for easier maintenance. Remove the doc8 line-length exception the old table needed. Docutils csv-table directive doesn't support colspan on the subheadings like the old table did. Add some JS that replicates the old behavior. (The new table is still readable even with JS disabled.)
This commit is contained in:
40
docs/_static/table-formatting.js
vendored
Normal file
40
docs/_static/table-formatting.js
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Return the first sibling of el that matches CSS selector, or null if no matches.
|
||||
* @param {HTMLElement} el
|
||||
* @param {string} selector
|
||||
* @returns {HTMLElement|null}
|
||||
*/
|
||||
function nextSiblingMatching(el, selector) {
|
||||
while (el && el.nextElementSibling) {
|
||||
el = el.nextElementSibling;
|
||||
if (el.matches(selector)) {
|
||||
return el;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert runs of empty <td> elements to a colspan on the first <td>.
|
||||
*/
|
||||
function collapseEmptyTableCells() {
|
||||
document.querySelectorAll(".rst-content tr:has(td:empty)").forEach((tr) => {
|
||||
for (
|
||||
let spanStart = tr.querySelector("td");
|
||||
spanStart;
|
||||
spanStart = nextSiblingMatching(spanStart, "td")
|
||||
) {
|
||||
let emptyCell;
|
||||
while ((emptyCell = nextSiblingMatching(spanStart, "td:empty"))) {
|
||||
emptyCell.remove();
|
||||
spanStart.colSpan++;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (document.readyState === "loading") {
|
||||
document.addEventListener("DOMContentLoaded", collapseEmptyTableCells);
|
||||
} else {
|
||||
collapseEmptyTableCells();
|
||||
}
|
||||
Reference in New Issue
Block a user