-
Notifications
You must be signed in to change notification settings - Fork 4
/
doc.go
43 lines (35 loc) · 1.42 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
envdoc is a tool to generate documentation for environment variables
from a Go source file. It is intended to be used as a go generate
directive.
For example, given the following Go type with struct tags and
a `go:generate` directive:
//go:generate go run github.com/g4s8/envdoc@latest -output config.md
type Config struct {
// Host name to listen on.
Host string `env:"HOST,required"`
// Port to listen on.
Port int `env:"PORT,notEmpty"`
// Debug mode enabled.
Debug bool `env:"DEBUG" envDefault:"false"`
}
Running go generate will generate the following Markdown file:
# Environment variables
- `HOST` (**required**) - Host name to listen on.
- `PORT` (**required**, not-empty) - Port to listen on.
- `DEBUG` (default: `false`) - Debug mode enabled.
By default envdoc generates documentation in Markdown format, but it
can also generate plaintext or HTML.
Options:
- `-output` - Output file name.
- `-type` - Type name to generate documentation for. Defaults for
the next type after `go:generate` directive.
- `-format` (default: `markdown`) - Set output format type, either `markdown`,
`plaintext` or `html`.
- `-all` - Generate documentation for all types in the file.
- `-env-prefix` - Environment variable prefix.
- `-no-styles` - Disable built-int CSS styles for HTML format.
- `-field-names` - Use field names instead of struct tags for variable names
if tags are not set.
*/
package main