docs: stdlib index sorted alphabetically
Signed-off-by: Sam Alba <sam.alba@gmail.com>
This commit is contained in:
parent
b5550d0766
commit
b03e695970
@ -8,6 +8,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
@ -365,6 +366,17 @@ func walkStdlib(ctx context.Context, output, format string) {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get filename from a package name
|
||||||
|
getFileName := func(p string) string {
|
||||||
|
filename := fmt.Sprintf("%s.%s", p, format)
|
||||||
|
// If this package has sub-packages (e.g. `aws`), create
|
||||||
|
// `aws/README.md` instead of `aws.md`.
|
||||||
|
if hasSubPackages(p) {
|
||||||
|
filename = fmt.Sprintf("%s/README.%s", p, format)
|
||||||
|
}
|
||||||
|
return filename
|
||||||
|
}
|
||||||
|
|
||||||
// Create main index
|
// Create main index
|
||||||
index, err := os.Create(path.Join(output, "README.md"))
|
index, err := os.Create(path.Join(output, "README.md"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -372,14 +384,10 @@ func walkStdlib(ctx context.Context, output, format string) {
|
|||||||
}
|
}
|
||||||
defer index.Close()
|
defer index.Close()
|
||||||
fmt.Fprintf(index, "# Index\n\n")
|
fmt.Fprintf(index, "# Index\n\n")
|
||||||
|
indexKeys := []string{}
|
||||||
|
|
||||||
for p, pkg := range packages {
|
for p, pkg := range packages {
|
||||||
filename := fmt.Sprintf("%s.%s", p, format)
|
filename := getFileName(p)
|
||||||
// If this package has sub-packages (e.g. `aws`), create
|
|
||||||
// `aws/README.md` instead of `aws.md`.
|
|
||||||
if hasSubPackages(p) {
|
|
||||||
filename = fmt.Sprintf("%s/README.%s", p, format)
|
|
||||||
}
|
|
||||||
filepath := path.Join(output, filename)
|
filepath := path.Join(output, filename)
|
||||||
|
|
||||||
if err := os.MkdirAll(path.Dir(filepath), 0755); err != nil {
|
if err := os.MkdirAll(path.Dir(filepath), 0755); err != nil {
|
||||||
@ -392,8 +400,13 @@ func walkStdlib(ctx context.Context, output, format string) {
|
|||||||
}
|
}
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
// FIXME: sort packages by name
|
indexKeys = append(indexKeys, p)
|
||||||
fmt.Fprintf(index, "- [%s](./%s)\n", p, filename)
|
|
||||||
fmt.Fprintf(f, "%s", pkg.Format(format))
|
fmt.Fprintf(f, "%s", pkg.Format(format))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate index from sorted list of packages
|
||||||
|
sort.Strings(indexKeys)
|
||||||
|
for _, p := range indexKeys {
|
||||||
|
fmt.Fprintf(index, "- [%s](./%s)\n", p, getFileName(p))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
# Index
|
# Index
|
||||||
|
|
||||||
- [aws](./aws/README.md)
|
|
||||||
- [aws/ecr](./aws/ecr.md)
|
|
||||||
- [aws/rds](./aws/rds.md)
|
|
||||||
- [git](./git.md)
|
|
||||||
- [kubernetes](./kubernetes/README.md)
|
|
||||||
- [terraform](./terraform.md)
|
|
||||||
- [random](./random.md)
|
|
||||||
- [aws/ecs](./aws/ecs.md)
|
|
||||||
- [aws/s3](./aws/s3.md)
|
|
||||||
- [dagger/op](./dagger/op.md)
|
|
||||||
- [gcp](./gcp/README.md)
|
|
||||||
- [go](./go.md)
|
|
||||||
- [js/yarn](./js/yarn.md)
|
|
||||||
- [kubernetes/helm](./kubernetes/helm.md)
|
|
||||||
- [docker](./docker.md)
|
|
||||||
- [gcp/gcr](./gcp/gcr.md)
|
|
||||||
- [gcp/gke](./gcp/gke.md)
|
|
||||||
- [io](./io.md)
|
|
||||||
- [kubernetes/kustomize](./kubernetes/kustomize.md)
|
|
||||||
- [os](./os.md)
|
|
||||||
- [alpine](./alpine.md)
|
- [alpine](./alpine.md)
|
||||||
|
- [aws](./aws/README.md)
|
||||||
- [aws/cloudformation](./aws/cloudformation.md)
|
- [aws/cloudformation](./aws/cloudformation.md)
|
||||||
|
- [aws/ecr](./aws/ecr.md)
|
||||||
|
- [aws/ecs](./aws/ecs.md)
|
||||||
- [aws/eks](./aws/eks.md)
|
- [aws/eks](./aws/eks.md)
|
||||||
- [aws/elb](./aws/elb.md)
|
- [aws/elb](./aws/elb.md)
|
||||||
|
- [aws/rds](./aws/rds.md)
|
||||||
|
- [aws/s3](./aws/s3.md)
|
||||||
- [dagger](./dagger/README.md)
|
- [dagger](./dagger/README.md)
|
||||||
|
- [dagger/op](./dagger/op.md)
|
||||||
|
- [docker](./docker.md)
|
||||||
|
- [gcp](./gcp/README.md)
|
||||||
|
- [gcp/gcr](./gcp/gcr.md)
|
||||||
|
- [gcp/gke](./gcp/gke.md)
|
||||||
|
- [git](./git.md)
|
||||||
|
- [go](./go.md)
|
||||||
|
- [io](./io.md)
|
||||||
|
- [js/yarn](./js/yarn.md)
|
||||||
|
- [kubernetes](./kubernetes/README.md)
|
||||||
|
- [kubernetes/helm](./kubernetes/helm.md)
|
||||||
|
- [kubernetes/kustomize](./kubernetes/kustomize.md)
|
||||||
- [netlify](./netlify.md)
|
- [netlify](./netlify.md)
|
||||||
|
- [os](./os.md)
|
||||||
|
- [random](./random.md)
|
||||||
|
- [terraform](./terraform.md)
|
||||||
|
Reference in New Issue
Block a user