1{% import "fmt" %}
2{% import "strings" %}
3{% import "git.sr.ht/~gabrielgio/apkdoc/parser" %}
4
5{% code
6func reduce(lines []string) string {
7 return strings.Join(lines, " ")
8}
9
10func formatLink(e *parser.Entry, format string) string {
11 c := strings.Replace(*e.Commit, "-dirty", "", -1)
12 return fmt.Sprintf(format, c, *e.Origin)
13}
14%}
15
16{% func MarkdownTemplate(entries []*parser.Entry, format string) %}
17# Apks Alpine 3.18
18{% for _, e := range entries %}
19## {%s e.Name %}
20
21- **Version**: {%s e.Version%}
22- **Description**: {%s e.Description%}{% if e.Maintainer != nil %}
23- **Maintainer**: {%s *e.Maintainer%}{% endif %}
24- **Checksum**:{%s e.Checksum%}{% if e.Architecture != nil %}
25- **Architecture**: {%s *e.Architecture%}{% endif %}
26- **Size**: {%d e.PackageSize%}B
27- **Installed size**: {%d e.InstalledSize%}
28- **Url**: {%s e.Url%}
29- **License**: {%s e.License%}{% if e.Origin != nil %}
30- **Origin**: {%s *e.Origin%}{% endif %}{% if e.BuildTime != nil %}
31- **Build time**: {%s e.BuildTime.String() %}{% endif %}{% if e.Commit != nil %}
32- **Commit**: [{%s *e.Commit %}]({%s formatLink(e, format) %}){% endif %}{% if e.ProviderPriority != nil %}
33- **Provider Priority**: {%d *e.ProviderPriority %}{% endif %}{% if len(e.Dependencies) > 0 %}
34- **Dependencies:**: {%s reduce(e.Dependencies) %}{% endif %}{% if len(e.Provides) > 0 %}
35- **Provides:**: {%s reduce(e.Provides) %}{% endif %}{% if len(e.InstallIf) > 0 %}
36- **Install if:**: {%s reduce(e.InstallIf) %}{% endif %}
37{% endfor %}
38
39{% endfunc %}