Skip to content

Commit ac074a2

Browse files
committed
Merge branch 'graphviz-diagrams' into gh-pages
This topic corresponds to git#2052. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 9aa6c9c + 884b895 commit ac074a2

File tree

12 files changed

+195
-4
lines changed

12 files changed

+195
-4
lines changed

.github/actions/deploy-to-github-pages/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ runs:
8181
find public/book public/docs -name \*.html -print0 |
8282
xargs -0r sed -i 's,http://git-scm\.com,https://git-scm.com,g'
8383
84+
- uses: actions/setup-node@v5
85+
- name: pre-render the Graphviz diagrams
86+
shell: bash
87+
run: |
88+
npm install node-html-parser &&
89+
node ./script/graphviz-ssr.js
90+
8491
- name: offer PDF version of the cheat sheet
8592
shell: bash
8693
run: |

.github/workflows/ci.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
exit 1
3333
fi
3434
35+
- uses: actions/setup-node@v5
36+
- name: pre-render the Graphviz diagrams
37+
run: |
38+
npm install node-html-parser &&
39+
node ./script/graphviz-ssr.js
40+
3541
- name: Install @playwright/test
3642
run: npm install @playwright/test
3743
- name: offer PDF version of the cheat sheet

assets/js/application.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,32 @@ var PostelizeAnchor = {
783783
},
784784
}
785785

786+
var Graphviz = {
787+
render: function() {
788+
let vizInstance
789+
[...document.querySelectorAll("pre[class=graphviz]")].forEach(async (x) => {
790+
if (!vizInstance) vizInstance = await Viz.instance()
791+
const options = {
792+
format: "svg",
793+
graphAttributes: {
794+
bgcolor: "transparent",
795+
},
796+
engine: x.getAttribute("engine") || "dot",
797+
}
798+
const svg = vizInstance.renderString(x.innerText, options)
799+
const img = document.createElement('img')
800+
img.setAttribute(
801+
'src',
802+
`data:image/svg+xml;utf8,${encodeURIComponent(svg.substring(svg.indexOf('<svg')))}`
803+
)
804+
const alt = x.getAttribute("alt")
805+
if (alt) img.setAttribute("alt", alt)
806+
x.parentNode.insertBefore(img, x);
807+
x.style.display = 'none'
808+
});
809+
}
810+
}
811+
786812
var Print = {
787813
init: function() {
788814
Print.tagline = $("#tagline");

content/about/distributed.html

Lines changed: 82 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,101 @@ <h4>Subversion-Style Workflow</h4>
2727
A centralized workflow is very common, especially from people transitioning from a centralized system. Git will not allow you to push if someone has pushed since the last time you fetched, so a centralized model where all developers push to the same server works just fine.
2828
</p>
2929
<p class="center">
30-
<img src="{{< relurl "images/about/[email protected]" >}}" width="415" height="209" alt="Workflow A">
30+
{{< graphviz alt="workflow A" >}}
31+
digraph dev_workflow {
32+
layout=neato;
33+
overlap=false;
34+
sep="+10";
35+
node [shape=box, style="filled,rounded", penwidth=0, fontname="Helvetica"];
36+
edge [penwidth=3, dir=both];
37+
38+
shared_repo [label="shared repository", fillcolor=teal, fontcolor=white, pos="2,1.5!"];
39+
40+
developer1 [label="developer", fillcolor=lightblue, pos="0,0!"];
41+
developer2 [label="developer", fillcolor=lightblue, pos="2,0!"];
42+
developer3 [label="developer", fillcolor=lightblue, pos="4,0!"];
43+
44+
developer1 -> shared_repo;
45+
developer2 -> shared_repo;
46+
developer3 -> shared_repo;
47+
}
48+
{{< /graphviz >}}
3149
</p>
3250
<h4>Integration Manager Workflow</h4>
3351
<p>
3452
Another common Git workflow involves an integration manager — a single person who commits to the 'blessed' repository. A number of developers then clone from that repository, push to their own independent repositories, and ask the integrator to pull in their changes. This is the type of development model often seen with open source or GitHub repositories.
3553
</p>
3654
<p class="center">
37-
<img src="{{< relurl "images/about/[email protected]" >}}" width="407" height="164" alt="Workflow B">
55+
{{< graphviz alt="workflow B" >}}
56+
digraph workflow {
57+
layout=neato;
58+
overlap=false;
59+
node [shape=box, style="filled,rounded", penwidth=0, fontname="Helvetica"];
60+
edge [penwidth=3];
61+
62+
// Nodes
63+
blessed_repo [label="blessed\nrepository", fillcolor=teal, fontcolor=white, margin="0.3", pos="0,3!"];
64+
integration_manager [label="integration\nmanager", fillcolor=orange, fontcolor=white, pos="0,1!"];
65+
66+
dev_pub1 [label="developer\npublic", fillcolor="#CCAA00", fontcolor=black, pos="2,3!"];
67+
dev_pub2 [label="developer\npublic", fillcolor="#CCAA00", fontcolor=black, pos="4,3!"];
68+
69+
dev_priv1 [label="developer\nprivate", fillcolor="#CCAA00", fontcolor=black, pos="2,1!"];
70+
dev_priv2 [label="developer\nprivate", fillcolor="#CCAA00", fontcolor=black, pos="4,1!"];
71+
72+
// Edges with labels
73+
dev_priv1 -> dev_pub1;
74+
dev_priv2 -> dev_pub2;
75+
integration_manager -> blessed_repo;
76+
77+
dev_pub1 -> integration_manager [color="gray"];
78+
dev_pub2 -> integration_manager [color="gray"];
79+
blessed_repo -> dev_priv1 [color="gray"];
80+
blessed_repo -> dev_priv2 [color="gray"];
81+
}
82+
{{< /graphviz >}}
3883
</p>
3984
<h4>Dictator and Lieutenants Workflow</h4>
4085
<p>
4186
For more massive projects, a development workflow like that of the Linux kernel is often effective.
4287
In this model, some people ('lieutenants') are in charge of a specific subsystem of the project and they merge in all changes related to that subsystem. Another integrator (the 'dictator') can pull changes from only his/her lieutenants and then push to the 'blessed' repository that everyone then clones from again.
4388
</p>
4489
<p class="center">
45-
<img src="{{< relurl "images/about/[email protected]" >}}" width="562" height="303" alt="Workflow C">
90+
{{< graphviz alt="workflow C" >}}
91+
digraph workflow {
92+
layout=neato;
93+
overlap=false;
94+
node [shape=box, style="filled,rounded", penwidth=0, fontname="Helvetica"];
95+
edge [fontname="Helvetica", penwidth=3];
96+
97+
// Nodes
98+
blessed_repo [label="blessed\nrepository", fillcolor=teal, fontcolor=white, margin="0.3", pos="6,4!"];
99+
dictator [label="dictator", fillcolor=red, fontcolor=white, pos="0,4!"];
100+
101+
lieutenant1 [label="lieutenant", fillcolor="#CCAA00", fontcolor=white, pos="0,2.5!"];
102+
lieutenant2 [label="lieutenant", fillcolor="#CCAA00", fontcolor=white, pos="2,3!"];
103+
104+
developer1 [label="developer", fillcolor=lightblue, fontcolor=black, pos="0,1!"];
105+
developer2 [label="developer", fillcolor=lightblue, fontcolor=black, pos="2,1!"];
106+
developer3 [label="developer", fillcolor=lightblue, fontcolor=black, pos="4,1!"];
107+
developer4 [label="developer", fillcolor=lightblue, fontcolor=black, pos="6,1!"];
108+
109+
// Edges
110+
dictator -> blessed_repo;
111+
lieutenant1 -> dictator;
112+
lieutenant2 -> dictator;
113+
114+
developer1 -> lieutenant1;
115+
developer2 -> lieutenant1;
116+
developer3 -> lieutenant2;
117+
developer4 -> lieutenant2;
118+
119+
blessed_repo -> developer1;
120+
blessed_repo -> developer2;
121+
blessed_repo -> developer3;
122+
blessed_repo -> developer4;
123+
}
124+
{{< /graphviz >}}
46125
</p>
47126
<div class="bottom-nav" style="display: block;">
48127
<a href="{{< relurl "about/small-and-fast" >}}" class="previous" data-section-id="small-and-fast">← Small and Fast</a>

content/diagram-list.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
outputs:
3+
- json
4+
---

hugo.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ markup:
1212
goldmark:
1313
renderer:
1414
unsafe: true
15+
mediaTypes:
16+
application/json:
17+
suffixes:
18+
- json
1519
module:
1620
mounts:
1721
- source: content

layouts/_default/baseof.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,9 @@ <h1 data-pagefind-meta="title">About{{ if (isset .Params "subtitle") }} - {{ .Pa
191191
{{ end }}
192192

193193
</body>
194+
{{ if .Page.Store.Get "hasGraphviz" -}}
195+
<script src="{{ relURL "js/viz-global.js" }}"> </script>
196+
<script type="text/javascript">Graphviz.render();</script>
197+
{{ end -}}
194198
</html>
195199
{{ end }}

layouts/_default/single.json.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{- $diagram_list := where .Site.Pages "RawContent" "like" "{{< graphviz" -}}
2+
{{- $diagram_list | jsonify -}}

layouts/shortcodes/graphviz.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<pre class="graphviz"{{ if (ne "" (.Get "engine")) }} engine="{{(.Get "engine")}}"{{ end }}{{ if (ne "" (.Get "alt")) }} alt="{{ (.Get "alt") }}"{{ end }}>
2+
{{ .Inner | htmlEscape | safeHTML }}
3+
</pre>
4+
{{ .Page.Store.Set "hasGraphviz" true }}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"license": "MIT",
66
"devDependencies": {
77
"@playwright/test": "^1.47.2",
8-
"@types/node": "^22.5.4"
8+
"@types/node": "^22.5.4",
9+
"node-html-parser": "^7.0.1"
910
}
1011
}

0 commit comments

Comments
 (0)