tools/generate.go: add defaults and enums to settings.md

package.json contains information about allowed values and defaults
which vscode-go and the settings editor know how to use.
With this change, generate.go puts this information into settings.md.

Change-Id: I8d869854b10d6e845c79beb1fa4fdaaac022c45c
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/249597
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/docs/settings.md b/docs/settings.md
index 997a5c0..30285b4 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -25,6 +25,14 @@
 
 Tags and options configured here will be used by the Add Tags command to add tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, json tags are added.
 
+Default:{<br/>
+&nbsp;&nbsp;`"options": "json=omitempty"`,<br/>
+&nbsp;&nbsp;`"promptForTags": false`,<br/>
+&nbsp;&nbsp;`"tags": "json"`,<br/>
+&nbsp;&nbsp;`"transform": "snakecase"`,<br/>
+    }
+
+
 ### `go.alternateTools`
 
 Alternate tools or alternate paths for the same tools used by the Go extension. Provide either absolute path or the name of the binary in GOPATH/bin, GOROOT/bin or PATH. Useful when you want to use wrapper script for the Go tools or versioned tools from https://gopkg.in.
@@ -33,6 +41,8 @@
 
 Include unimported packages in auto-complete suggestions.
 
+Default: `false`
+
 ### `go.buildFlags`
 
 Flags to `go build`/`go test` used during build-on-save or running tests. (e.g. ["-ldflags='-s'"])
@@ -41,65 +51,138 @@
 
 Compiles code on file save using 'go build -i' or 'go test -c -i'. Options are 'workspace', 'package', or 'off'.
 
+Allowed Values:`[package workspace off]`
+
+Default: `package`
+
 ### `go.buildTags`
 
 The Go build tags to use for all commands, that support a `-tags '...'` argument. When running tests, go.testTags will be used instead if it was set.
 
+Default: ``
+
 ### `go.coverMode`
 
-When generating code coverage, the value for -covermode: 'set', 'count', 'atomic'
+When generating code coverage, the value for -covermode
+
+Allowed Values:`[set count atomic]`
+
+Default: `set`
 
 ### `go.coverOnSave`
 
 If true, runs 'go test -coverprofile' on save and shows test coverage.
 
+Default: `false`
+
 ### `go.coverOnSingleTest`
 
 If true, shows test coverage when Go: Test Function at cursor command is run.
 
+Default: `false`
+
 ### `go.coverOnSingleTestFile`
 
 If true, shows test coverage when Go: Test Single File command is run.
 
+Default: `false`
+
 ### `go.coverOnTestPackage`
 
 If true, shows test coverage when Go: Test Package command is run.
 
+Default: `true`
+
 ### `go.coverShowCounts`
 
 When generating code coverage, should counts be shown as --374--
 
+Default: `false`
+
 ### `go.coverageDecorator`
 
-This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the colors for the former and the style for the latter.
+This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the colors and borders for the former and the style for the latter.
+
+Default:{<br/>
+&nbsp;&nbsp;`"coveredBorderColor": "rgba(64,128,128,0.5)"`,<br/>
+&nbsp;&nbsp;`"coveredGutterStyle": "blockblue"`,<br/>
+&nbsp;&nbsp;`"coveredHighlightColor": "rgba(64,128,128,0.5)"`,<br/>
+&nbsp;&nbsp;`"type": "highlight"`,<br/>
+&nbsp;&nbsp;`"uncoveredBorderColor": "rgba(128,64,64,0.25)"`,<br/>
+&nbsp;&nbsp;`"uncoveredGutterStyle": "slashyellow"`,<br/>
+&nbsp;&nbsp;`"uncoveredHighlightColor": "rgba(128,64,64,0.25)"`,<br/>
+    }
+
 
 ### `go.coverageOptions`
 
 Use these options to control whether only covered or only uncovered code or both should be highlighted after running test coverage
 
+Allowed Values:`[showCoveredCodeOnly showUncoveredCodeOnly showBothCoveredAndUncoveredCode]`
+
+Default: `showBothCoveredAndUncoveredCode`
+
 ### `go.delveConfig`
 
 Delve settings that applies to all debugging sessions. Debug configuration in the launch.json file will override these values.
 
+Default:{<br/>
+&nbsp;&nbsp;`"apiVersion": 2`,<br/>
+&nbsp;&nbsp;`"dlvLoadConfig": map[followPointers:true maxArrayValues:64 maxStringLen:64 maxStructFields:-1 maxVariableRecurse:1]`,<br/>
+&nbsp;&nbsp;`"showGlobalVariables": true`,<br/>
+    }
+
+
 ### `go.docsTool`
 
 Pick 'godoc' or 'gogetdoc' to get documentation. Not applicable when using the language server.
 
+Allowed Values:`[godoc gogetdoc guru]`
+
+Default: `godoc`
+
 ### `go.editorContextMenuCommands`
 
 Experimental Feature: Enable/Disable entries from the context menu in the editor.
 
+Default:{<br/>
+&nbsp;&nbsp;`"addImport": true`,<br/>
+&nbsp;&nbsp;`"addTags": true`,<br/>
+&nbsp;&nbsp;`"debugTestAtCursor": true`,<br/>
+&nbsp;&nbsp;`"generateTestForFile": false`,<br/>
+&nbsp;&nbsp;`"generateTestForFunction": true`,<br/>
+&nbsp;&nbsp;`"generateTestForPackage": false`,<br/>
+&nbsp;&nbsp;`"playground": true`,<br/>
+&nbsp;&nbsp;`"removeTags": false`,<br/>
+&nbsp;&nbsp;`"testAtCursor": true`,<br/>
+&nbsp;&nbsp;`"testCoverage": true`,<br/>
+&nbsp;&nbsp;`"testFile": false`,<br/>
+&nbsp;&nbsp;`"testPackage": false`,<br/>
+&nbsp;&nbsp;`"toggleTestFile": true`,<br/>
+    }
+
+
 ### `go.enableCodeLens`
 
 Feature level setting to enable/disable code lens for references and run/debug tests
 
+Default:{<br/>
+&nbsp;&nbsp;`"references": false`,<br/>
+&nbsp;&nbsp;`"runtest": true`,<br/>
+    }
+
+
 ### `go.formatFlags`
 
 Flags to pass to format tool (e.g. ["-s"])
 
 ### `go.formatTool`
 
-Pick 'gofmt', 'goimports', 'goreturns' or 'goformat' to run on format. Not applicable when using the language server. Choosing 'goimports' or 'goreturns' will add missing imports and remove unused imports.
+Not applicable when using the language server. Choosing 'goimports' or 'goreturns' will add missing imports and remove unused imports.
+
+Allowed Values:`[gofmt goimports goreturns goformat]`
+
+Default: `goreturns`
 
 ### `go.generateTestsFlags`
 
@@ -109,22 +192,34 @@
 
 Enable gocode's autobuild feature. Not applicable when using the language server.
 
+Default: `false`
+
 ### `go.gocodeFlags`
 
 Additional flags to pass to gocode. Not applicable when using the language server.
 
+Default: `[-builtin -ignore-case -unimported-packages]`
+
 ### `go.gocodePackageLookupMode`
 
 Used to determine the Go package lookup rules for completions by gocode. Only applies when using nsf/gocode. Latest versions of the Go extension uses mdempsky/gocode by default. Not applicable when using the language server.
 
+Allowed Values:`[go gb bzl]`
+
+Default: `go`
+
 ### `go.gopath`
 
 Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
 
+efault: `<nil>`
+
 ### `go.goroot`
 
 Specifies the GOROOT to use when no environment variable is set.
 
+efault: `<nil>`
+
 ### `go.gotoSymbol.ignoreFolders`
 
 Folder names (not paths) to ignore while using Go to Symbol in Workspace feature
@@ -133,22 +228,36 @@
 
 If false, the standard library located at $GOROOT will be excluded while using the Go to Symbol in File feature
 
+Default: `false`
+
 ### `go.gotoSymbol.includeImports`
 
 If false, the import statements will be excluded while using the Go to Symbol in File feature
 
+Default: `false`
+
 ### `go.inferGopath`
 
 Infer GOPATH from the workspace root.
 
+Default: `false`
+
 ### `go.installDependenciesWhenBuilding`
 
 If true, then `-i` flag will be passed to `go build` everytime the code is compiled.
 
+Default: `true`
+
 ### `go.languageServerExperimentalFeatures`
 
 Use this setting to enable/disable experimental features from the language server.
 
+Default:{<br/>
+&nbsp;&nbsp;`"diagnostics": true`,<br/>
+&nbsp;&nbsp;`"documentLink": true`,<br/>
+    }
+
+
 ### `go.languageServerFlags`
 
 Flags like -rpc.trace and -logfile to be used while running the language server.
@@ -161,30 +270,60 @@
 
 Lints code on file save using the configured Lint tool. Options are 'file', 'package', 'workspace' or 'off'.
 
+Allowed Values:`[file package workspace off]`
+
+Default: `package`
+
 ### `go.lintTool`
 
 Specifies Lint tool name.
 
+Allowed Values:`[golint golangci-lint revive staticcheck]`
+
+Default: `golint`
+
 ### `go.liveErrors`
 
 Use gotype on the file currently being edited and report any semantic or syntactic errors found after configured delay.
 
+Default:{<br/>
+&nbsp;&nbsp;`"delay": 500`,<br/>
+&nbsp;&nbsp;`"enabled": false`,<br/>
+    }
+
+
 ### `go.overwriteGoplsMiddleware`
 
 This option provides a set of flags which determine if vscode-go should intercept certain commands from gopls. These flags assume the `gopls` settings, which enable codelens from gopls, are also present.
 
 ### `go.playground`
 
+The flags configured here will be passed through to command `goplay`
+
+Default:{<br/>
+&nbsp;&nbsp;`"openbrowser": true`,<br/>
+&nbsp;&nbsp;`"run": true`,<br/>
+&nbsp;&nbsp;`"share": true`,<br/>
+    }
 
 
 ### `go.removeTags`
 
 Tags and options configured here will be used by the Remove Tags command to remove tags to struct fields. If promptForTags is true, then user will be prompted for tags and options. By default, all tags and options will be removed.
 
+Default:{<br/>
+&nbsp;&nbsp;`"options": ""`,<br/>
+&nbsp;&nbsp;`"promptForTags": false`,<br/>
+&nbsp;&nbsp;`"tags": ""`,<br/>
+    }
+
+
 ### `go.testEnvFile`
 
 Absolute path to a file containing environment variables definitions. File contents should be of the form key=value.
 
+Default: `<nil>`
+
 ### `go.testEnvVars`
 
 Environment variables that will passed to the process that runs the Go tests
@@ -193,18 +332,26 @@
 
 Flags to pass to `go test`. If null, then buildFlags will be used.
 
+efault: `<nil>`
+
 ### `go.testOnSave`
 
 Run 'go test' on save for current package. It is not advised to set this to `true` when you have Auto Save enabled.
 
+Default: `false`
+
 ### `go.testTags`
 
 The Go build tags to use for when running tests. If null, then buildTags will be used.
 
+efault: `<nil>`
+
 ### `go.testTimeout`
 
 Specifies the timeout for go test in ParseDuration format.
 
+Default: `30s`
+
 ### `go.toolsEnvVars`
 
 Environment variables that will passed to the processes that run the Go tools (e.g. CGO_CFLAGS)
@@ -213,30 +360,48 @@
 
 Location to install the Go tools that the extension depends on if you don't want them in your GOPATH.
 
+Default: ``
+
 ### `go.trace.server`
 
 Trace the communication between VS Code and the Go language server.
 
+Allowed Values:`[off messages verbose]`
+
+Default: `off`
+
 ### `go.useCodeSnippetsOnFunctionSuggest`
 
 Complete functions with their parameter signature, including the variable types
 
+Default: `false`
+
 ### `go.useCodeSnippetsOnFunctionSuggestWithoutType`
 
 Complete functions with their parameter signature, excluding the variable types
 
+Default: `false`
+
 ### `go.useGoProxyToCheckForToolUpdates`
 
 When enabled, the extension automatically checks the Go proxy if there are updates available for Go and the Go tools (at present, only gopls) it depends on and prompts the user accordingly
 
+Default: `true`
+
 ### `go.useLanguageServer`
 
 Use the Go language server "gopls" from Google for powering language features like code navigation, completion, formatting & diagnostics.
 
+Default: `false`
+
 ### `go.vetFlags`
 
 Flags to pass to `go tool vet` (e.g. ["-all", "-shadow"])
 
 ### `go.vetOnSave`
 
-Vets code on file save using 'go tool vet'. Options are 'workspace', 'package or 'off'.
+Vets code on file save using 'go tool vet'.
+
+Allowed Values:`[package workspace off]`
+
+Default: `package`
diff --git a/package.json b/package.json
index 9e7e8ab..cc30ef9 100644
--- a/package.json
+++ b/package.json
@@ -1219,7 +1219,7 @@
             "off"
           ],
           "default": "package",
-          "description": "Vets code on file save using 'go tool vet'. Options are 'workspace', 'package or 'off'.",
+          "description": "Vets code on file save using 'go tool vet'.",
           "scope": "resource"
         },
         "go.vetFlags": {
@@ -1234,7 +1234,7 @@
         "go.formatTool": {
           "type": "string",
           "default": "goreturns",
-          "description": "Pick 'gofmt', 'goimports', 'goreturns' or 'goformat' to run on format. Not applicable when using the language server. Choosing 'goimports' or 'goreturns' will add missing imports and remove unused imports.",
+          "description": "Not applicable when using the language server. Choosing 'goimports' or 'goreturns' will add missing imports and remove unused imports.",
           "scope": "resource",
           "enum": [
             "gofmt",
@@ -1311,13 +1311,13 @@
         },
         "go.coverMode": {
           "type": "string",
-          "enum:": [
+          "enum": [
             "set",
             "count",
             "atomic"
           ],
           "default": "set",
-          "description": "When generating code coverage, the value for -covermode: 'set', 'count', 'atomic'",
+          "description": "When generating code coverage, the value for -covermode",
           "scope": "resource"
         },
         "go.coverShowCounts": {
@@ -1409,7 +1409,7 @@
             "coveredGutterStyle": "blockblue",
             "uncoveredGutterStyle": "slashyellow"
           },
-          "description": "This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the colors for the former and the style for the latter.",
+          "description": "This option lets you choose the way to display code coverage. Choose either to highlight the complete line or to show a decorator in the gutter. You can customize the colors and borders for the former and the style for the latter.",
           "scope": "resource"
         },
         "go.testTimeout": {
@@ -1729,9 +1729,9 @@
               "type": "boolean",
               "default": true,
               "description": "Whether to run the created Go Playground after creation"
-            },
-            "description": "The flags configured here will be passed through to command `goplay`"
+            }
           },
+          "description": "The flags configured here will be passed through to command `goplay`",
           "additionalProperties": false,
           "default": {
             "openbrowser": true,
diff --git a/tools/generate.go b/tools/generate.go
index f93ce88..4afaca6 100644
--- a/tools/generate.go
+++ b/tools/generate.go
@@ -43,6 +43,7 @@
 	Default     interface{} `json:"default,omitempty"`
 	Description string      `json:"description,omitempty"`
 	Type        interface{} `json:"type,omitempty"`
+	Enum        []string    `json:"enum,omitempty"`
 }
 
 func main() {
@@ -116,13 +117,56 @@
 			Default:     p.Default,
 			Description: p.Description,
 			Type:        p.Type,
+			Enum:        p.Enum,
 		})
 	}
 	sort.Slice(properties, func(i, j int) bool {
 		return properties[i].Name < properties[j].Name
 	})
+	indent := "&nbsp;&nbsp;"
 	for i, p := range properties {
 		b.WriteString(fmt.Sprintf("### `%s`\n\n%s", p.Name, p.Description))
+		if p.Enum != nil {
+			b.WriteString(fmt.Sprintf("\n\nAllowed Values:`%v`", p.Enum))
+		}
+		switch p.Type {
+		case "object":
+			x, ok := p.Default.(map[string]interface{})
+			// do nothing if it is nil
+			if ok && len(x) > 0 {
+				keys := []string{}
+				for k := range x {
+					keys = append(keys, k)
+				}
+				sort.Strings(keys)
+				b.WriteString(fmt.Sprintf("\n\nDefault:{<br/>\n"))
+				for _, k := range keys {
+					v := x[k]
+					output := fmt.Sprintf("%v", v)
+					if str, ok := v.(string); ok {
+						output = fmt.Sprintf("%q", str)
+					}
+					// if v is an empty string, nothing gets printed
+					// if v is a map/object, it is printed on one line
+					// this could be improved at the cost of more code
+					b.WriteString(fmt.Sprintf("%s`\"%s\": %s`,<br/>\n", indent, k, output))
+				}
+				b.WriteString("    }\n")
+			}
+		case "boolean", "string", "number":
+			b.WriteString(fmt.Sprintf("\n\nDefault: `%v`", p.Default))
+		case "array":
+			x := p.Default.([]interface{})
+			if len(x) > 0 {
+				b.WriteString(fmt.Sprintf("\n\nDefault: `%v`", p.Default))
+			}
+		default:
+			if _, ok := p.Type.([]interface{}); ok {
+				b.WriteString(fmt.Sprintf("\n\nefault: `%v`", p.Default))
+				break
+			}
+			log.Fatalf("implement default when p.Type is %q in %#v %T", p.Type, p, p.Default)
+		}
 		if i != len(properties)-1 {
 			b.WriteString("\n\n")
 		}