Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/generate_docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,6 @@ func extractFlagsForEngine(flagSet *pflag.FlagSet, config interface{}, engineNam
}

flagSet.VisitAll(func(current *pflag.Flag) {
println(current.Name, engineName)
if current.Name == engineName ||
strings.HasPrefix(current.Name, engineName+".") {
// This flag belongs to this engine, so copy it and hide it in the input flag set
Expand Down Expand Up @@ -248,9 +247,10 @@ func generateRstTable(tableName, fileName string, values [][]rstValue) {
panic(err)
}
defer optionsFile.Close()
optionsFile.WriteString(fmt.Sprintf(".. table:: %s\n", tableName))
optionsFile.WriteString(fmt.Sprintf(".. list-table:: %s\n", tableName))
optionsFile.WriteString(" :widths: 20 30 50\n")
optionsFile.WriteString(" :class: options-table\n\n")
optionsFile.WriteString(" :class: options-table\n")
optionsFile.WriteString(" :header-rows: 1\n\n")
printRstTable(vals("Key", "Default", "Description"), values, optionsFile)
if err := optionsFile.Sync(); err != nil {
panic(err)
Expand Down
27 changes: 27 additions & 0 deletions docs/generate_docs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,36 @@ package main

import (
"sort"
"strings"
"testing"
)

func TestPrintRstTable(t *testing.T) {
var buf strings.Builder
printRstTable(vals("Key", "Default", "Description"), [][]rstValue{
{{value: "HTTP", bold: true}},
vals("http.public.address", ":8080", "Public address"),
vals("cpuprofile", "", "CPU profile path"),
}, &buf)

expected := ` * - Key
- Default
- Description
* - **HTTP**
-
-
* - http.public.address
- \:8080
- Public address
* - cpuprofile
-
- CPU profile path
`
if buf.String() != expected {
t.Errorf("unexpected list-table output:\ngot:\n%s\nwant:\n%s", buf.String(), expected)
}
}

func TestKeyList(t *testing.T) {
got := KeyList{
[]rstValue{{value: "storage.bbolt.backup.directory"}},
Expand Down
Loading
Loading