aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-26 21:47:47 +0200
committerGabriel Arakaki Giovanini <mail@gabrielgio.me>2023-08-26 21:47:47 +0200
commit33727db8bee991115906d3408145d5e0806a2455 (patch)
tree29676f914f103e6198e48ff5514aace1ca3a97d4 /templates
parentdd2a1c38a5a9f561d58b58da56d3230fd715fcde (diff)
downloadapkdoc-33727db8bee991115906d3408145d5e0806a2455.tar.gz
apkdoc-33727db8bee991115906d3408145d5e0806a2455.tar.bz2
apkdoc-33727db8bee991115906d3408145d5e0806a2455.zip
feat: Add initial template renderer for markdown
Diffstat (limited to 'templates')
-rw-r--r--templates/index.md.qtpl33
-rw-r--r--templates/index.md.qtpl.go215
2 files changed, 248 insertions, 0 deletions
diff --git a/templates/index.md.qtpl b/templates/index.md.qtpl
new file mode 100644
index 0000000..879795a
--- /dev/null
+++ b/templates/index.md.qtpl
@@ -0,0 +1,33 @@
+{% import "git.sr.ht/~gabrielgio/apkdoc/parser" %}
+{% import "strings" %}
+
+{% code
+func reduce(lines []string) string {
+ return strings.Join(lines, " ")
+}
+%}
+
+{% func MarkdownTemplate(entries []*parser.Entry) %}
+# Apks Alpine 3.18
+{% for _, e := range entries %}
+## {%s e.Name %}
+
+**Version**: {%s e.Version%}
+**Description**: {%s e.Description%}
+{% if e.Maintainer != nil %}**Maintainer**: {%s *e.Maintainer%}{% endif %}
+**Checksum**:{%s e.Checksum%}
+{% if e.Architecture != nil %}**Architecture**: {%s *e.Architecture%}{% endif %}
+**Size**: {%d e.PackageSize%}B
+**Installed size**: {%d e.InstalledSize%}
+**Url**: {%s e.Url%}
+**License**: {%s e.License%}
+{% if e.Origin != nil %}**Origin**: {%s *e.Origin%}{% endif %}
+{% if e.BuildTime != nil %}**Build time**: {%s e.BuildTime.String() %}{% endif %}
+{% if e.Commit != nil %}**Commit**: {%s *e.Commit %}{% endif %}
+{% if e.ProviderPriority != nil %}**Provider Priority**: {%d *e.ProviderPriority %}{% endif %}
+{% if len(e.Dependencies) > 0 %}**Dependencies:**: {%s reduce(e.Dependencies) %}{% endif %}
+{% if len(e.Provides) > 0 %}**Provides:**: {%s reduce(e.Provides) %}{% endif %}
+{% if len(e.InstallIf) > 0 %}**Install if:**: {%s reduce(e.InstallIf) %}{% endif %}
+{% endfor %}
+
+{% endfunc %}
diff --git a/templates/index.md.qtpl.go b/templates/index.md.qtpl.go
new file mode 100644
index 0000000..af3d34a
--- /dev/null
+++ b/templates/index.md.qtpl.go
@@ -0,0 +1,215 @@
+// Code generated by qtc from "index.md.qtpl". DO NOT EDIT.
+// See https://github.com/valyala/quicktemplate for details.
+
+//line index.md.qtpl:1
+package templates
+
+//line index.md.qtpl:1
+import "git.sr.ht/~gabrielgio/apkdoc/parser"
+
+//line index.md.qtpl:2
+import "strings"
+
+//line index.md.qtpl:4
+import (
+ qtio422016 "io"
+
+ qt422016 "github.com/valyala/quicktemplate"
+)
+
+//line index.md.qtpl:4
+var (
+ _ = qtio422016.Copy
+ _ = qt422016.AcquireByteBuffer
+)
+
+//line index.md.qtpl:5
+func reduce(lines []string) string {
+ return strings.Join(lines, " ")
+}
+
+//line index.md.qtpl:10
+func StreamMarkdownTemplate(qw422016 *qt422016.Writer, entries []*parser.Entry) {
+//line index.md.qtpl:10
+ qw422016.N().S(`
+# Apks Alpine 3.18
+`)
+//line index.md.qtpl:12
+ for _, e := range entries {
+//line index.md.qtpl:12
+ qw422016.N().S(`
+## `)
+//line index.md.qtpl:13
+ qw422016.E().S(e.Name)
+//line index.md.qtpl:13
+ qw422016.N().S(`
+
+**Version**: `)
+//line index.md.qtpl:15
+ qw422016.E().S(e.Version)
+//line index.md.qtpl:15
+ qw422016.N().S(`
+**Description**: `)
+//line index.md.qtpl:16
+ qw422016.E().S(e.Description)
+//line index.md.qtpl:16
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:17
+ if e.Maintainer != nil {
+//line index.md.qtpl:17
+ qw422016.N().S(`**Maintainer**: `)
+//line index.md.qtpl:17
+ qw422016.E().S(*e.Maintainer)
+//line index.md.qtpl:17
+ }
+//line index.md.qtpl:17
+ qw422016.N().S(`
+**Checksum**:`)
+//line index.md.qtpl:18
+ qw422016.E().S(e.Checksum)
+//line index.md.qtpl:18
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:19
+ if e.Architecture != nil {
+//line index.md.qtpl:19
+ qw422016.N().S(`**Architecture**: `)
+//line index.md.qtpl:19
+ qw422016.E().S(*e.Architecture)
+//line index.md.qtpl:19
+ }
+//line index.md.qtpl:19
+ qw422016.N().S(`
+**Size**: `)
+//line index.md.qtpl:20
+ qw422016.N().D(e.PackageSize)
+//line index.md.qtpl:20
+ qw422016.N().S(`B
+**Installed size**: `)
+//line index.md.qtpl:21
+ qw422016.N().D(e.InstalledSize)
+//line index.md.qtpl:21
+ qw422016.N().S(`
+**Url**: `)
+//line index.md.qtpl:22
+ qw422016.E().S(e.Url)
+//line index.md.qtpl:22
+ qw422016.N().S(`
+**License**: `)
+//line index.md.qtpl:23
+ qw422016.E().S(e.License)
+//line index.md.qtpl:23
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:24
+ if e.Origin != nil {
+//line index.md.qtpl:24
+ qw422016.N().S(`**Origin**: `)
+//line index.md.qtpl:24
+ qw422016.E().S(*e.Origin)
+//line index.md.qtpl:24
+ }
+//line index.md.qtpl:24
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:25
+ if e.BuildTime != nil {
+//line index.md.qtpl:25
+ qw422016.N().S(`**Build time**: `)
+//line index.md.qtpl:25
+ qw422016.E().S(e.BuildTime.String())
+//line index.md.qtpl:25
+ }
+//line index.md.qtpl:25
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:26
+ if e.Commit != nil {
+//line index.md.qtpl:26
+ qw422016.N().S(`**Commit**: `)
+//line index.md.qtpl:26
+ qw422016.E().S(*e.Commit)
+//line index.md.qtpl:26
+ }
+//line index.md.qtpl:26
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:27
+ if e.ProviderPriority != nil {
+//line index.md.qtpl:27
+ qw422016.N().S(`**Provider Priority**: `)
+//line index.md.qtpl:27
+ qw422016.N().D(*e.ProviderPriority)
+//line index.md.qtpl:27
+ }
+//line index.md.qtpl:27
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:28
+ if len(e.Dependencies) > 0 {
+//line index.md.qtpl:28
+ qw422016.N().S(`**Dependencies:**: `)
+//line index.md.qtpl:28
+ qw422016.E().S(reduce(e.Dependencies))
+//line index.md.qtpl:28
+ }
+//line index.md.qtpl:28
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:29
+ if len(e.Provides) > 0 {
+//line index.md.qtpl:29
+ qw422016.N().S(`**Provides:**: `)
+//line index.md.qtpl:29
+ qw422016.E().S(reduce(e.Provides))
+//line index.md.qtpl:29
+ }
+//line index.md.qtpl:29
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:30
+ if len(e.InstallIf) > 0 {
+//line index.md.qtpl:30
+ qw422016.N().S(`**Install if:**: `)
+//line index.md.qtpl:30
+ qw422016.E().S(reduce(e.InstallIf))
+//line index.md.qtpl:30
+ }
+//line index.md.qtpl:30
+ qw422016.N().S(`
+`)
+//line index.md.qtpl:31
+ }
+//line index.md.qtpl:31
+ qw422016.N().S(`
+
+`)
+//line index.md.qtpl:33
+}
+
+//line index.md.qtpl:33
+func WriteMarkdownTemplate(qq422016 qtio422016.Writer, entries []*parser.Entry) {
+//line index.md.qtpl:33
+ qw422016 := qt422016.AcquireWriter(qq422016)
+//line index.md.qtpl:33
+ StreamMarkdownTemplate(qw422016, entries)
+//line index.md.qtpl:33
+ qt422016.ReleaseWriter(qw422016)
+//line index.md.qtpl:33
+}
+
+//line index.md.qtpl:33
+func MarkdownTemplate(entries []*parser.Entry) string {
+//line index.md.qtpl:33
+ qb422016 := qt422016.AcquireByteBuffer()
+//line index.md.qtpl:33
+ WriteMarkdownTemplate(qb422016, entries)
+//line index.md.qtpl:33
+ qs422016 := string(qb422016.B)
+//line index.md.qtpl:33
+ qt422016.ReleaseByteBuffer(qb422016)
+//line index.md.qtpl:33
+ return qs422016
+//line index.md.qtpl:33
+}