~sircmpwn/godocs.io

gddo: gddo-server: Fix package examples v1 APPLIED

Adnan Maolood: 1
 gddo-server: Fix package examples

 2 files changed, 5 insertions(+), 1 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/godocs.io/patches/22532/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH gddo] gddo-server: Fix package examples Export this patch

---
This wasn't working because the *Package was embedded in another struct.

 gddo-server/assets/templates/doc.html | 2 +-
 gddo-server/template.go               | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gddo-server/assets/templates/doc.html b/gddo-server/assets/templates/doc.html
index 20c1b49..71deb70 100644
--- a/gddo-server/assets/templates/doc.html
+++ b/gddo-server/assets/templates/doc.html
@@ -16,7 +16,7 @@
    {{.Doc|comment}}
  {{end}}

  {{template "Examples" .|$.ObjExamples}}
  {{template "Examples" .PackageExamples}}

  {{if not .IsCommand}}
    <h3 id="pkg-index" class="section-header">Index <a class="permalink" href="#pkg-index">&para;</a></h3>
diff --git a/gddo-server/template.go b/gddo-server/template.go
index 85567d8..e5ca2c8 100644
--- a/gddo-server/template.go
+++ b/gddo-server/template.go
@@ -176,6 +176,10 @@ func (pdoc *Package) AllExamples() []*texample {
	return pdoc.allExamples
}

func (pdoc *Package) PackageExamples() []*texample {
	return pdoc.ObjExamples(pdoc)
}

func (pdoc *Package) ObjExamples(obj interface{}) []*texample {
	var examples []*texample
	for _, e := range pdoc.allExamples {
-- 
2.31.1
Thanks!

To git@git.sr.ht:~sircmpwn/gddo
   fee53a7..2904362  master -> master