Skip to content

Commit 81477f3

Browse files
authored
Create task-to-md-mermaid.gomplate
Based and inspired by : - go-task/task#2503 - go-task/task#2348
1 parent 155611a commit 81477f3

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tmpl/task-to-md-mermaid.gomplate

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{{- $tasks := (ds "tasks").tasks -}}
2+
# Taskfile Workflow Diagram
3+
4+
This diagram visualizes the dependencies and flow between tasks defined in `Taskfile.yml` :
5+
6+
```mermaid
7+
graph TD
8+
{{- range $name, $_ := $tasks }}
9+
{{- if eq $name "default" }}
10+
default["**default**"]:::defaultNode
11+
{{- else }}
12+
{{ $name }}[{{ $name }}]
13+
{{- end }}
14+
{{- end }}
15+
16+
{{- range $name, $task := $tasks }}
17+
{{- if (has $task "deps") }}
18+
{{- range $dep := $task.deps }}
19+
{{ $name }} -- deps --> {{ $dep }}
20+
{{- end }}
21+
{{- end }}
22+
{{- if and (eq $name "default") (has $task "cmds") }}
23+
{{- range $cmd := $task.cmds }}
24+
{{- if (strings.HasPrefix $cmd "task ") }}
25+
{{- $dep := (strings.TrimPrefix "task " $cmd) }}
26+
default -- deps --> {{ $dep }}
27+
{{- end }}
28+
{{- end }}
29+
{{- end }}
30+
{{- end }}
31+
32+
classDef defaultNode fill:#1976D2,color:#fff,stroke:#333,stroke-width:2px;
33+
```
34+
35+
36+
## Task Goals and Descriptions
37+
38+
| Task Name | Description |
39+
|-------------- |---------------------------------------------------------------------------------------------------|
40+
{{- range $name, $task := $tasks }}
41+
| {{ $name }} | {{ $task.desc }} |
42+
{{- end }}
43+
44+
---
45+
46+
Copy and paste the Mermaid code into a Markdown viewer that supports Mermaid to see the graph rendered visually.

0 commit comments

Comments
 (0)