context-mapper 0.21.0__tar.gz → 0.22.1__tar.gz
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.
- {context_mapper-0.21.0 → context_mapper-0.22.1}/PKG-INFO +3 -3
- {context_mapper-0.21.0 → context_mapper-0.22.1}/README.md +2 -2
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/build.py +3 -1
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/mermaid.py +15 -1
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/template/app.js +12 -3
- context_mapper-0.22.1/src/context_mapper/template/download.js +89 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/template/index.html +16 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/template/style.css +3 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/PKG-INFO +3 -3
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/SOURCES.txt +1 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/scm_file_list.json +1 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/scm_version.json +2 -2
- {context_mapper-0.21.0 → context_mapper-0.22.1}/tests/test_build.py +13 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/tests/test_mermaid.py +11 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/.github/workflows/ci.yml +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/.github/workflows/pages.yml +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/.github/workflows/publish.yml +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/.gitignore +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/LICENSE +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/docs/screenshot.png +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/example/context-map.style.yml +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/example/context-map.yml +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/pyproject.toml +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/setup.cfg +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/__init__.py +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/__main__.py +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/graph.py +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper/serve.py +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/dependency_links.txt +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/entry_points.txt +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/requires.txt +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/top_level.txt +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/tests/conftest.py +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/tests/test_graph.py +0 -0
- {context_mapper-0.21.0 → context_mapper-0.22.1}/tests/test_serve.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: context-mapper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.22.1
|
|
4
4
|
Summary: Builds an interactive context map and Mermaid diagrams from a YAML domain model.
|
|
5
5
|
Author-email: Henrique Moody <henriquemoody@gmail.com>
|
|
6
6
|
License-Expression: ISC
|
|
@@ -109,8 +109,8 @@ At domain level, context dependencies are lifted to their domains and merged, an
|
|
|
109
109
|
|
|
110
110
|
| Output | What it is |
|
|
111
111
|
| --- | --- |
|
|
112
|
-
| `<out>/index.html` | Interactive view. Switch between bounded contexts and domains, click anything to focus on it, hide anything from the side panel, hover a box or an arrow for the details. |
|
|
113
|
-
| `<out>/mermaid/*.html` | One static Mermaid page per domain, per bounded context, and per named view. Click a box to jump to its page. |
|
|
112
|
+
| `<out>/index.html` | Interactive view. Switch between bounded contexts and domains, click anything to focus on it, hide anything from the side panel, hover a box or an arrow for the details, download the view as a PNG or SVG image. |
|
|
113
|
+
| `<out>/mermaid/*.html` | One static Mermaid page per domain, per bounded context, and per named view. Click a box to jump to its page, download the diagram as a PNG or SVG image. |
|
|
114
114
|
| `<out>/markdown/*.md` | The same diagrams as Markdown. GitLab renders them natively, and they can go to Confluence. |
|
|
115
115
|
|
|
116
116
|
## Run locally
|
|
@@ -80,8 +80,8 @@ At domain level, context dependencies are lifted to their domains and merged, an
|
|
|
80
80
|
|
|
81
81
|
| Output | What it is |
|
|
82
82
|
| --- | --- |
|
|
83
|
-
| `<out>/index.html` | Interactive view. Switch between bounded contexts and domains, click anything to focus on it, hide anything from the side panel, hover a box or an arrow for the details. |
|
|
84
|
-
| `<out>/mermaid/*.html` | One static Mermaid page per domain, per bounded context, and per named view. Click a box to jump to its page. |
|
|
83
|
+
| `<out>/index.html` | Interactive view. Switch between bounded contexts and domains, click anything to focus on it, hide anything from the side panel, hover a box or an arrow for the details, download the view as a PNG or SVG image. |
|
|
84
|
+
| `<out>/mermaid/*.html` | One static Mermaid page per domain, per bounded context, and per named view. Click a box to jump to its page, download the diagram as a PNG or SVG image. |
|
|
85
85
|
| `<out>/markdown/*.md` | The same diagrams as Markdown. GitLab renders them natively, and they can go to Confluence. |
|
|
86
86
|
|
|
87
87
|
## Run locally
|
|
@@ -119,7 +119,9 @@ def render_index(payload):
|
|
|
119
119
|
"""The interactive page: the skeleton with the stylesheet, the script and the model spliced in."""
|
|
120
120
|
html = (TEMPLATE_DIR / "index.html").read_text()
|
|
121
121
|
css = (TEMPLATE_DIR / "style.css").read_text().strip()
|
|
122
|
-
|
|
122
|
+
download = (TEMPLATE_DIR / "download.js").read_text().strip()
|
|
123
|
+
js = (TEMPLATE_DIR / "app.js").read_text().replace("/*__MODEL__*/null", payload)
|
|
124
|
+
js = js.replace("/*__DOWNLOAD__*/", download).strip()
|
|
123
125
|
return html.replace("/*__STYLE__*/", css).replace("/*__SCRIPT__*/", js)
|
|
124
126
|
|
|
125
127
|
|
|
@@ -6,6 +6,7 @@ there and the README for every option. build.py calls `build(data, config, out)`
|
|
|
6
6
|
import html
|
|
7
7
|
import json
|
|
8
8
|
import re
|
|
9
|
+
import textwrap
|
|
9
10
|
from pathlib import Path
|
|
10
11
|
|
|
11
12
|
from . import graph
|
|
@@ -451,6 +452,10 @@ def check(data, cfg):
|
|
|
451
452
|
return errors
|
|
452
453
|
|
|
453
454
|
|
|
455
|
+
# The download script is shared with the interactive page: build.py splices it
|
|
456
|
+
# into app.js, here it goes into every static diagram page's script.
|
|
457
|
+
DOWNLOAD_JS = (Path(__file__).parent / "template" / "download.js").read_text().strip()
|
|
458
|
+
|
|
454
459
|
PAGE = """<!doctype html>
|
|
455
460
|
<html lang="en">
|
|
456
461
|
<head>
|
|
@@ -485,7 +490,8 @@ PAGE = """<!doctype html>
|
|
|
485
490
|
</html>
|
|
486
491
|
"""
|
|
487
492
|
|
|
488
|
-
DIAGRAM = """<
|
|
493
|
+
DIAGRAM = """<p class="hint">Download: <a href="#" data-download="png">PNG</a> · <a href="#" data-download="svg">SVG</a></p>
|
|
494
|
+
<div id="diagram">Loading diagram...</div>
|
|
489
495
|
{relations}
|
|
490
496
|
<details><summary>Mermaid source</summary><pre>{escaped}</pre></details>
|
|
491
497
|
<script type="text/plain" id="source">{raw}</script>
|
|
@@ -502,6 +508,12 @@ DIAGRAM = """<div id="diagram">Loading diagram...</div>
|
|
|
502
508
|
}} catch (err) {{
|
|
503
509
|
el.textContent = "Could not render this diagram: " + err.message;
|
|
504
510
|
}}
|
|
511
|
+
document.querySelectorAll("[data-download]").forEach(a => a.addEventListener("click", ev => {{
|
|
512
|
+
ev.preventDefault();
|
|
513
|
+
const svg = el.querySelector("svg");
|
|
514
|
+
if (svg) downloadDiagram(svg, a.dataset.download, {name});
|
|
515
|
+
}}));
|
|
516
|
+
__DOWNLOAD__
|
|
505
517
|
</script>"""
|
|
506
518
|
|
|
507
519
|
ELK = ('const { default: elkLayouts } = await import("https://cdn.jsdelivr.net/npm/@mermaid-js/layout-elk@0/dist/mermaid-layout-elk.esm.min.mjs");\n'
|
|
@@ -612,7 +624,9 @@ def build(data, config, out):
|
|
|
612
624
|
escaped=html.escape(source),
|
|
613
625
|
raw=source,
|
|
614
626
|
elk=ELK if uses_elk(cfg) else "",
|
|
627
|
+
name=json.dumps(view["id"]),
|
|
615
628
|
)
|
|
629
|
+
body = body.replace("__DOWNLOAD__", textwrap.indent(DOWNLOAD_JS, " "))
|
|
616
630
|
(html_dir / f"{view['id']}.html").write_text(PAGE.format(
|
|
617
631
|
title=html.escape(title),
|
|
618
632
|
about=f'<p class="hint">{html.escape(about)}</p>' if about else "",
|
|
@@ -570,10 +570,9 @@ const chip = type => { const t = MODEL.types[type]; return `<span class="chip" s
|
|
|
570
570
|
|
|
571
571
|
function renderInfo(s, visible) {
|
|
572
572
|
const legend = '<div class="legend">' + Object.keys(MODEL.types).map(chip).join("") + "</div>";
|
|
573
|
-
const howTo = `<h3>How to read</h3><p class="hint">An arrow from A to B means A depends on B. Upstream is at the top. The outer boxes are domains, the coloured boxes inside them are bounded contexts. The Show & hide form in the right panel has a control for every domain and cluster: a multi-context domain or a cluster can be expanded (the boxes inside it), collapsed (one box), or hidden — a dashed underline marks a cluster's — and a one-box domain hides with a toggle. Focusing on a domain or a cluster lists what it holds, and each item there can be hidden too. Click a box to focus on it.</p>`;
|
|
574
573
|
if (!s.focus) {
|
|
575
574
|
$("info").innerHTML = `<h2>Whole system</h2><p class="hint">${visible.size} items shown. Pick a domain, cluster or bounded context to see only what it touches.</p>
|
|
576
|
-
<p><a href="mermaid/index.html">Static diagrams</a></p>${legend}
|
|
575
|
+
<p><a href="mermaid/index.html">Static diagrams</a></p>${legend}`;
|
|
577
576
|
return;
|
|
578
577
|
}
|
|
579
578
|
const id = s.focus;
|
|
@@ -608,7 +607,7 @@ function renderInfo(s, visible) {
|
|
|
608
607
|
if (dDowns.length) html += `<h3>${pname} as a whole is used by</h3>${list(dDowns)}`;
|
|
609
608
|
}
|
|
610
609
|
}
|
|
611
|
-
$("info").innerHTML = html + `<h3>Legend</h3>${legend}
|
|
610
|
+
$("info").innerHTML = html + `<h3>Legend</h3>${legend}`;
|
|
612
611
|
}
|
|
613
612
|
|
|
614
613
|
const setHidden = (id, hide) => {
|
|
@@ -632,5 +631,15 @@ Object.entries(displaySels).forEach(([id, sel]) => sel.addEventListener("change"
|
|
|
632
631
|
$("reset").addEventListener("click", () => { history.replaceState(null, "", location.pathname); readHash(); render(); });
|
|
633
632
|
window.addEventListener("hashchange", () => { readHash(); render(); });
|
|
634
633
|
|
|
634
|
+
// Downloading the diagram as it stands, named after what it shows.
|
|
635
|
+
$("download").addEventListener("click", () => {
|
|
636
|
+
const svg = $("graph").querySelector("svg");
|
|
637
|
+
if (!svg) return; // nothing rendered to download
|
|
638
|
+
const s = state();
|
|
639
|
+
const name = ["context-map", s.focus, s.level === "domain" ? "domain" : null].filter(Boolean).join("-");
|
|
640
|
+
downloadDiagram(svg, $("image").value, name);
|
|
641
|
+
});
|
|
642
|
+
|
|
635
643
|
readHash();
|
|
636
644
|
render();
|
|
645
|
+
/*__DOWNLOAD__*/
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// Downloading the rendered diagram as an image. build.py splices this into
|
|
2
|
+
// app.js for the interactive page; mermaid.py splices it into the script of
|
|
3
|
+
// every static diagram page, so both offer the same export.
|
|
4
|
+
|
|
5
|
+
// The diagram as a standalone SVG: a text the file holds, and the size it
|
|
6
|
+
// opens at. What only makes sense on the page goes out — the wide
|
|
7
|
+
// transparent copies that catch hover on an arrow, the accent arrowheads
|
|
8
|
+
// hover lights up (a hovered arrow points at its copy, so point it back at
|
|
9
|
+
// the original before dropping it), and the links that navigate within the
|
|
10
|
+
// site. A file of its own has none of the page's CSS either: the size comes
|
|
11
|
+
// from the viewBox, in pixels, instead of the stylesheet's width rules.
|
|
12
|
+
function standaloneSvg(svg) {
|
|
13
|
+
const clone = svg.cloneNode(true);
|
|
14
|
+
clone.classList.remove("hovering");
|
|
15
|
+
clone.querySelectorAll(".edge-hit").forEach(n => n.remove());
|
|
16
|
+
clone.querySelectorAll("[id$='-on']").forEach(copy => {
|
|
17
|
+
const original = copy.id.slice(0, -3);
|
|
18
|
+
clone.querySelectorAll("[marker-end]").forEach(el => {
|
|
19
|
+
if (el.getAttribute("marker-end").includes(copy.id))
|
|
20
|
+
el.setAttribute("marker-end", `url(#${original})`);
|
|
21
|
+
});
|
|
22
|
+
copy.remove();
|
|
23
|
+
});
|
|
24
|
+
clone.querySelectorAll("a").forEach(a => {
|
|
25
|
+
a.removeAttribute("href");
|
|
26
|
+
a.removeAttributeNS("http://www.w3.org/1999/xlink", "href");
|
|
27
|
+
});
|
|
28
|
+
const parts = (clone.getAttribute("viewBox") || "").trim().split(/\s+/).map(Number);
|
|
29
|
+
const width = parts.length === 4 ? parts[2] : svg.getBoundingClientRect().width;
|
|
30
|
+
const height = parts.length === 4 ? parts[3] : svg.getBoundingClientRect().height;
|
|
31
|
+
clone.setAttribute("width", Math.round(width));
|
|
32
|
+
clone.setAttribute("height", Math.round(height));
|
|
33
|
+
clone.removeAttribute("style");
|
|
34
|
+
// The font the labels show on the page is the page's own — Mermaid writes
|
|
35
|
+
// no font-family into the drawing — and the page's stylesheet doesn't
|
|
36
|
+
// travel with the file. Bake in the family the live diagram computes, so
|
|
37
|
+
// the download keeps what the screen shows.
|
|
38
|
+
clone.style.fontFamily = getComputedStyle(svg).fontFamily;
|
|
39
|
+
// The page paints the diagram's background; a file of its own needs one of
|
|
40
|
+
// its own, the same color, or a dark slide or a dark-mode README turns it
|
|
41
|
+
// into dark text on a dark page. The viewBox need not start at 0, so the
|
|
42
|
+
// rect covers it, not the corner the axes cross at.
|
|
43
|
+
const background = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
44
|
+
if (parts.length === 4) {
|
|
45
|
+
background.setAttribute("x", parts[0]);
|
|
46
|
+
background.setAttribute("y", parts[1]);
|
|
47
|
+
}
|
|
48
|
+
background.setAttribute("width", "100%");
|
|
49
|
+
background.setAttribute("height", "100%");
|
|
50
|
+
const pageBg = getComputedStyle(document.body).backgroundColor;
|
|
51
|
+
background.setAttribute("fill", pageBg === "rgba(0, 0, 0, 0)" ? "#ffffff" : pageBg);
|
|
52
|
+
clone.insertBefore(background, clone.firstChild);
|
|
53
|
+
return { text: '<?xml version="1.0" encoding="UTF-8"?>\n' + new XMLSerializer().serializeToString(clone),
|
|
54
|
+
width: Math.round(width), height: Math.round(height) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function saveBlob(blob, filename) {
|
|
58
|
+
const a = document.createElement("a");
|
|
59
|
+
a.href = URL.createObjectURL(blob);
|
|
60
|
+
a.download = filename;
|
|
61
|
+
a.click();
|
|
62
|
+
setTimeout(() => URL.revokeObjectURL(a.href), 1000);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// `svg` is the rendered diagram, `format` "png" or "svg", `name` the file
|
|
66
|
+
// name without its extension. The PNG draws the SVG on a canvas at twice
|
|
67
|
+
// its size, on the page's own background, so the image looks like the
|
|
68
|
+
// diagram does on screen.
|
|
69
|
+
function downloadDiagram(svg, format, name) {
|
|
70
|
+
const { text, width, height } = standaloneSvg(svg);
|
|
71
|
+
if (format === "svg") {
|
|
72
|
+
saveBlob(new Blob([text], { type: "image/svg+xml;charset=utf-8" }), name + ".svg");
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const scale = Math.min(2, 16384 / Math.max(width, height)); // stay under the canvas limit
|
|
76
|
+
const canvas = document.createElement("canvas");
|
|
77
|
+
canvas.width = Math.round(width * scale);
|
|
78
|
+
canvas.height = Math.round(height * scale);
|
|
79
|
+
const img = new Image();
|
|
80
|
+
img.onload = () => {
|
|
81
|
+
const ctx = canvas.getContext("2d");
|
|
82
|
+
const bg = getComputedStyle(document.body).backgroundColor;
|
|
83
|
+
ctx.fillStyle = bg === "rgba(0, 0, 0, 0)" ? "#ffffff" : bg;
|
|
84
|
+
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
85
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
86
|
+
canvas.toBlob(blob => blob && saveBlob(blob, name + ".png"), "image/png");
|
|
87
|
+
};
|
|
88
|
+
img.src = "data:image/svg+xml;charset=utf-8," + encodeURIComponent(text);
|
|
89
|
+
}
|
|
@@ -41,7 +41,23 @@
|
|
|
41
41
|
<div id="graph"></div>
|
|
42
42
|
<aside id="panel">
|
|
43
43
|
<div id="info"></div>
|
|
44
|
+
<div id="export">
|
|
45
|
+
<h3>Download</h3>
|
|
46
|
+
<div class="row">
|
|
47
|
+
<label>Image
|
|
48
|
+
<select id="image">
|
|
49
|
+
<option value="png">PNG</option>
|
|
50
|
+
<option value="svg">SVG</option>
|
|
51
|
+
</select>
|
|
52
|
+
</label>
|
|
53
|
+
<button id="download">Download</button>
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
44
56
|
<div id="display"><h3>Show & hide</h3></div>
|
|
57
|
+
<div id="howto">
|
|
58
|
+
<h3>How to read</h3>
|
|
59
|
+
<p class="hint">An arrow from A to B means A depends on B. Upstream is at the top. The outer boxes are domains, the coloured boxes inside them are bounded contexts. The Show & hide form in the right panel has a control for every domain and cluster: a multi-context domain or a cluster can be expanded (the boxes inside it), collapsed (one box), or hidden — a dashed underline marks a cluster's — and a one-box domain hides with a toggle. Focusing on a domain or a cluster lists what it holds, and each item there can be hidden too. Click a box to focus on it. Download saves the diagram you are looking at as a PNG or SVG image.</p>
|
|
60
|
+
</div>
|
|
45
61
|
</aside>
|
|
46
62
|
</main>
|
|
47
63
|
<script type="module">
|
|
@@ -47,6 +47,9 @@ aside a:hover { text-decoration: underline; }
|
|
|
47
47
|
#display .cluster { border-bottom: 2px dashed var(--muted); }
|
|
48
48
|
aside .toggle { color: var(--muted); font-size: 13px; }
|
|
49
49
|
aside .toggle::before { content: "· "; color: var(--line); }
|
|
50
|
+
/* The panel's download controls: the image format on the left, the button that saves with it on the right. */
|
|
51
|
+
#export .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; }
|
|
52
|
+
#export .row select { padding: 2px 6px; }
|
|
50
53
|
@media (max-width: 800px) {
|
|
51
54
|
main { grid-template-columns: 1fr; grid-template-rows: 60vh auto; height: auto; }
|
|
52
55
|
aside { border-left: 0; border-top: 1px solid var(--line); }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: context-mapper
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.22.1
|
|
4
4
|
Summary: Builds an interactive context map and Mermaid diagrams from a YAML domain model.
|
|
5
5
|
Author-email: Henrique Moody <henriquemoody@gmail.com>
|
|
6
6
|
License-Expression: ISC
|
|
@@ -109,8 +109,8 @@ At domain level, context dependencies are lifted to their domains and merged, an
|
|
|
109
109
|
|
|
110
110
|
| Output | What it is |
|
|
111
111
|
| --- | --- |
|
|
112
|
-
| `<out>/index.html` | Interactive view. Switch between bounded contexts and domains, click anything to focus on it, hide anything from the side panel, hover a box or an arrow for the details. |
|
|
113
|
-
| `<out>/mermaid/*.html` | One static Mermaid page per domain, per bounded context, and per named view. Click a box to jump to its page. |
|
|
112
|
+
| `<out>/index.html` | Interactive view. Switch between bounded contexts and domains, click anything to focus on it, hide anything from the side panel, hover a box or an arrow for the details, download the view as a PNG or SVG image. |
|
|
113
|
+
| `<out>/mermaid/*.html` | One static Mermaid page per domain, per bounded context, and per named view. Click a box to jump to its page, download the diagram as a PNG or SVG image. |
|
|
114
114
|
| `<out>/markdown/*.md` | The same diagrams as Markdown. GitLab renders them natively, and they can go to Confluence. |
|
|
115
115
|
|
|
116
116
|
## Run locally
|
|
@@ -23,6 +23,7 @@ src/context_mapper.egg-info/scm_file_list.json
|
|
|
23
23
|
src/context_mapper.egg-info/scm_version.json
|
|
24
24
|
src/context_mapper.egg-info/top_level.txt
|
|
25
25
|
src/context_mapper/template/app.js
|
|
26
|
+
src/context_mapper/template/download.js
|
|
26
27
|
src/context_mapper/template/index.html
|
|
27
28
|
src/context_mapper/template/style.css
|
|
28
29
|
tests/conftest.py
|
{context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/scm_file_list.json
RENAMED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"src/context_mapper/mermaid.py",
|
|
18
18
|
"src/context_mapper/serve.py",
|
|
19
19
|
"src/context_mapper/template/app.js",
|
|
20
|
+
"src/context_mapper/template/download.js",
|
|
20
21
|
"src/context_mapper/template/index.html",
|
|
21
22
|
"src/context_mapper/template/style.css",
|
|
22
23
|
"tests/conftest.py",
|
|
@@ -218,6 +218,19 @@ def test_box_tooltips_map_node_ids_back_to_items(tmp_path):
|
|
|
218
218
|
assert "descriptionOf" not in text # no lookup by SVG id left
|
|
219
219
|
|
|
220
220
|
|
|
221
|
+
def test_the_interactive_page_can_download_the_diagram(tmp_path):
|
|
222
|
+
out = tmp_path / "public"
|
|
223
|
+
build.main(["--model", str(EXAMPLE_MODEL), "--diagrams", str(EXAMPLE_STYLE), "--out", str(out)])
|
|
224
|
+
text = (out / "index.html").read_text()
|
|
225
|
+
assert '<select id="image">' in text # PNG or SVG
|
|
226
|
+
assert '<option value="png">PNG</option>' in text
|
|
227
|
+
assert '<option value="svg">SVG</option>' in text
|
|
228
|
+
assert '<button id="download">Download</button>' in text
|
|
229
|
+
assert "function downloadDiagram" in text # the shared export script, spliced in
|
|
230
|
+
assert "getComputedStyle(svg).fontFamily" in text # the page's font travels with the file
|
|
231
|
+
assert "/*__DOWNLOAD__*/" not in text # never left behind
|
|
232
|
+
|
|
233
|
+
|
|
221
234
|
def test_main_puts_the_links_in_the_page(tmp_path):
|
|
222
235
|
style = example_style_without_links(tmp_path, "links:\n Repository: https://github.com/org/repo\n")
|
|
223
236
|
out = tmp_path / "public"
|
|
@@ -529,6 +529,17 @@ def test_build_writes_the_diagram_into_the_page(tmp_path, example_data, example_
|
|
|
529
529
|
assert "```mermaid" in markdown
|
|
530
530
|
|
|
531
531
|
|
|
532
|
+
def test_build_writes_the_download_links_into_the_page(tmp_path, example_data, example_style):
|
|
533
|
+
mermaid.build(example_data, example_style["mermaid"], tmp_path)
|
|
534
|
+
page = (tmp_path / "mermaid" / "overview.html").read_text()
|
|
535
|
+
assert 'data-download="png"' in page
|
|
536
|
+
assert 'data-download="svg"' in page
|
|
537
|
+
assert "function downloadDiagram" in page # the shared export script, spliced in
|
|
538
|
+
assert "getComputedStyle(svg).fontFamily" in page # the page's font travels with the file
|
|
539
|
+
assert "__DOWNLOAD__" not in page # never left behind
|
|
540
|
+
assert 'downloadDiagram(svg, a.dataset.download, "overview")' in page
|
|
541
|
+
|
|
542
|
+
|
|
532
543
|
# --- describe and item_description -------------------------------------------
|
|
533
544
|
|
|
534
545
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{context_mapper-0.21.0 → context_mapper-0.22.1}/src/context_mapper.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|