Skip to content

Commit

Permalink
add godoc in generated readme
Browse files Browse the repository at this point in the history
  • Loading branch information
bobheadxi committed Jul 28, 2019
1 parent f841d51 commit 7eba799
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion config.go
Expand Up @@ -6,7 +6,8 @@ type canonical struct {
}

type config struct {
Packages map[string]canonical
GodocFromSource bool
Packages map[string]canonical
}

func newConfig() *config {
Expand Down
13 changes: 11 additions & 2 deletions generate.go
Expand Up @@ -68,11 +68,20 @@ func generateREADME(cfg *config) {

// render table
table := tablewriter.NewWriter(f)
table.SetHeader([]string{"Package", "Source"})
table.SetHeader([]string{"Package", "Godoc", "Source"})
table.SetBorders(tablewriter.Border{Left: true, Top: false, Right: true, Bottom: false})
table.SetCenterSeparator("|")
for _, k := range keys {
table.Append([]string{cfg.Packages[k].Path, fmt.Sprintf("[%s](https://%s)", k, k)})
pkgPath := cfg.Packages[k].Path
godocSource := pkgPath
if cfg.GodocFromSource {
godocSource = k
}
table.Append([]string{
fmt.Sprintf("`%s`", pkgPath),
fmt.Sprintf("[![GoDoc](https://godoc.org/%s?status.svg)](https://godoc.org/%s)", godocSource, godocSource),
fmt.Sprintf("[%s](https://%s)", k, k),
})
}
table.Render()
f.WriteString("\n---\n")
Expand Down

0 comments on commit 7eba799

Please sign in to comment.