ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - g4s8/envdoc: Go tool to generate documentation for environment variables
Go tool to generate documentation for environment variables - g4s8/envdoc
Visit Site

GitHub - g4s8/envdoc: Go tool to generate documentation for environment variables

GitHub - g4s8/envdoc: Go tool to generate documentation for environment variables

envdoc

envdoc is a tool for generating documentation for environment variables in Go structs. It takes comments associated with env tags in Go structs and creates a Markdown, plaintext or HTML file with detailed documentation.

For docenv linter see docenv/README.md.

CI Go Reference codecov Go Report Card Mentioned in Awesome Go

Installation

Run it with go run in source file:

//go:generate go run github.com/g4s8/envdoc@latest -output environments.md -type Config
type Config struct {
    // ...
}

Or download binary to run it:

go install github.com/g4s8/envdoc@latest

And use it in code:

//go:generate envdoc -output environments.md
type Config struct {
    // ...
}

Usage

//go:generate envdoc -output <output_file_name>
  • -dir (path string, optional) - Specify the directory to search for files. Default is the file dir with go:generate command.
  • -files (glob string, optional) - File glob pattern to specify file names to process. Default is the single file with go:generate.
  • -types (glob string, optional) - Type glob pattern for type names to process. If not specified, the next type after go:generate is used.
  • -output (path string, required) - Output file name for generated documentation.
  • -format (enum(markdown, plaintext, html, dotenv) string, optional) - Output format for documentation. Default is markdown.
  • -no-styles (bool, optional) - If true, CSS styles will not be included for html format.
  • -env-prefix (string, optional) - Sets additional global prefix for all environment variables.
  • -tag-name (string, optional, default: env) - Use custom tag name instead of env.
  • -tag-default (string, optional, default: envDefault) - Use "default" tag name instead of envDefault.
  • -required-if-no-def (bool, optional, default: false) - Set attributes as required if no default value is set.
  • -field-names (bool, optional) - Use field names as env names if env: tag is not specified.
  • -debug (bool, optional) - Enable debug output.

These params are deprecated and will be removed in the next major release:

  • -type - Specify one type to process.
  • -all - Process all types in a file.

Both parameters could be replaced with -types param:

  • Use -types=Foo instead of -type=Foo.
  • Use -types='*' instead of -all.

Example

Suppose you have the following Go file config.go:

package foo

//go:generate envdoc --output env-doc.md
type Config struct {
  // Port to listen for incoming connections
  Port int `env:"PORT,required"`
  // Address to serve
  Address string `env:"ADDRESS" envDefault:"localhost"`
}

And the go:generate line above creates documentation in env-doc.md file:

# Environment Variables

- `PORT` (**required**) - Port to listen for incoming connections
- `ADDRESS` (default: `localhost`) - Address to serve

See _examples dir for more details.

Compatibility

This tool is compatible with

Let me know about any new lib to check compatibility.

Contributing

If you find any issues or have suggestions for improvement, feel free to open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory