Skip to content

Commit

Permalink
Allow hidden repositories (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
ptxmac authored Jan 31, 2022
1 parent 2833fc5 commit bc7c053
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ The repository `type` and `source` properties will be set automatically when `ur
"template"
],
"type": "git",
"hidden": false,
"url": "https://github.com/leighmcculloch/go-optional",
"source": {
"home": "https://github.com/leighmcculloch/go-optional",
Expand All @@ -112,4 +113,3 @@ The repository `type` and `source` properties will be set automatically when `ur
]
}
```

1 change: 1 addition & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type repository struct {
Type string `json:"type"`
URL string `json:"url"`
Main bool `json:"main"`
Hidden bool `json:"hidden"`
SourceURLs sourceURLs `json:"source"`
Website website `json:"website"`
}
Expand Down
4 changes: 2 additions & 2 deletions generate_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ body { margin-top: 0; }
<h3>Libraries:</h3>
<ul>
{{range $_, $r := .PackageRepositories -}}
{{range $_, $r := .PackageRepositories -}}{{if not $r.Hidden -}}
<li>
<a href="/{{$r.Prefix}}">{{$r.Prefix}}</a>
{{if .Subs -}}<ul>{{end -}}
{{range $_, $s := .Subs -}}{{if not $s.Hidden -}}<li><a href="/{{$r.Prefix}}/{{$s.Name}}">{{$s.Name}}</a></li>{{end -}}{{end -}}
{{if .Subs -}}</ul>{{end -}}
</li>
{{end -}}
{{end }}{{end -}}
</ul>
<hr/>
Expand Down
4 changes: 4 additions & 0 deletions generate_index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func TestGenerateIndex(t *testing.T) {
Prefix: "pkg2",
Subs: []sub{{Name: "subpkg1"}, {Name: "subpkg2/subsubpkg1"}},
},
{
Prefix: "pkg3",
Hidden: true,
},
},
expectedOut: `<!DOCTYPE html>
<html>
Expand Down
39 changes: 39 additions & 0 deletions generate_package_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,45 @@ Home: <a href="https://godoc.org/example.com/pkg1">https://godoc.org/example.com
Source: <a href="https://repositoryhost.com/example/go-pkg1">https://repositoryhost.com/example/go-pkg1</a><br/>
Sub-packages:<ul><li><a href="/pkg1/subpkg1">example.com/pkg1/subpkg1</a></li><li><a href="/pkg1/subpkg2">example.com/pkg1/subpkg2</a></li></ul></div>
</body>
</html>`,
expectedErr: nil,
},
{
description: "hidden",
domain: "example.com",
docsDomain: "godoc.org",
pkg: "pkg1",
r: repository{
Prefix: "pkg1",
Hidden: true,
Subs: []sub{{Name: "subpkg1"}, {Name: "subpkg2"}},
Type: "git",
URL: "https://repositoryhost.com/example/go-pkg1",
},
expectedOut: `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>example.com/pkg1</title>
<meta name="go-import" content="example.com/pkg1 git https://repositoryhost.com/example/go-pkg1">
<meta name="go-source" content="example.com/pkg1 _ _ _">
<style>
* { font-family: sans-serif; }
body { margin-top: 0; }
.content { display: inline-block; }
code { display: block; font-family: monospace; font-size: 1em; background-color: #d5d5d5; padding: 1em; margin-bottom: 16px; }
ul { margin-top: 16px; margin-bottom: 16px; }
</style>
</head>
<body>
<div class="content">
<h2>example.com/pkg1</h2>
<code>go get example.com/pkg1</code>
<code>import "example.com/pkg1"</code>
Home: <a href="https://godoc.org/example.com/pkg1">https://godoc.org/example.com/pkg1</a><br/>
Source: <a href="https://repositoryhost.com/example/go-pkg1">https://repositoryhost.com/example/go-pkg1</a><br/>
Sub-packages:<ul><li><a href="/pkg1/subpkg1">example.com/pkg1/subpkg1</a></li><li><a href="/pkg1/subpkg2">example.com/pkg1/subpkg2</a></li></ul></div>
</body>
</html>`,
expectedErr: nil,
},
Expand Down

0 comments on commit bc7c053

Please sign in to comment.