From 9a95dcbf6ef077808a8874beea9d8a2754e60051 Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Mon, 23 Jan 2023 09:53:51 -0800 Subject: Add support for package descriptions (#68) * template: Use a more fluid layout Instead of using a table, take advantage of the grid layout. We still print a table of sorts, but it's more fluid in appearance based on width of the screen. On narrower screens, we'll show a listing where each item has a description label next to it rather than at the top. * Add support for package descrpitions Packages may now optionally specify a description. If specified, this is printed below the package information, indented one column to make it stand out. Co-authored-by: Sung Yoon Whang --- CHANGELOG.md | 3 ++- README.md | 3 +++ config.go | 2 ++ handler_test.go | 2 ++ sally.yaml | 1 + templates/index.html | 11 +++++++++++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31295a3..3f92d7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -### Changed +### Added +- Add an optional `description` field to packages. - Use a fluid layout for the index page. This renders better on narrow screens. diff --git a/README.md b/README.md index ae1888d..92a8da1 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,9 @@ packages: # Defaults to "master". branch: master + # Optional description of the package. + description: A fast, structured-logging library. + # Alternative base URL instead of the value configured at the top-level. # This is useful if the same sally instance is # hosted behind multiple base URLs. diff --git a/config.go b/config.go index d562154..57b5dcd 100644 --- a/config.go +++ b/config.go @@ -26,6 +26,8 @@ type Package struct { Repo string `yaml:"repo"` Branch string `yaml:"branch"` URL string `yaml:"url"` + + Desc string `yaml:"description"` // plain text only } // Parse takes a path to a yaml file and produces a parsed Config diff --git a/handler_test.go b/handler_test.go index 96a10dd..e300d19 100644 --- a/handler_test.go +++ b/handler_test.go @@ -17,6 +17,7 @@ packages: zap: url: go.uberalt.org repo: github.com/uber-go/zap + description: A fast, structured logging library. ` @@ -27,6 +28,7 @@ func TestIndex(t *testing.T) { body := rr.Body.String() assert.Contains(t, body, "github.com/thriftrw/thriftrw-go") assert.Contains(t, body, "github.com/yarpc/yarpc-go") + assert.Contains(t, body, "A fast, structured logging library.") } func TestPackageShouldExist(t *testing.T) { diff --git a/sally.yaml b/sally.yaml index ee8ff87..c9a3af8 100644 --- a/sally.yaml +++ b/sally.yaml @@ -3,5 +3,6 @@ url: go.uber.org packages: thriftrw: repo: github.com/thriftrw/thriftrw-go + description: A customizable implementation of Thrift. yarpc: repo: github.com/yarpc/yarpc-go diff --git a/templates/index.html b/templates/index.html index 3fc210c..d193263 100644 --- a/templates/index.html +++ b/templates/index.html @@ -7,6 +7,7 @@ .separator { margin: 0.25em 0; } + .description { color: #666; } /* On narrow screens, switch to inline headers. */ .table-header { display: none; } @@ -44,6 +45,16 @@ + {{ with .Desc }} +
+
+ +
+
+ {{ . }} +
+
+ {{ end }} {{ end }} -- cgit v1.2.3