Skip to content

Commit

Permalink
add README
Browse files Browse the repository at this point in the history
Signed-off-by: jkoberg <[email protected]>
  • Loading branch information
kobergj committed Dec 13, 2022
1 parent 8627f06 commit ddee772
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions docs/helpers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Docs Helpers

`docs/helpers` contains a small go program creating docs by extracting information from the code. It has three main responsibilities
- Generate docs for envvars in config structs
- Extract envvars that are not mentioned in config structs (aka "Rogue" envvars)
- Generate docs for rogue envvars

## Generate Envvar docs for config structs

Generates docs from a template file, mainly extracting `"env"` and `"desc"` tags from the config structs.

Templates can be found in `docs/helpers` folder. (Same as this `README`.) Check `.tmpl` files

## Extract Rogue Envvars

It `grep`s over the code, looking for `os.Getenv` and parses these contents to a yaml file along with the following information:
```golang
// Variable contains all information about one rogue envvar
type Variable struct {
// These field structs are automatically filled:
// RawName can be the name of the envvar or the name of its var
RawName string `yaml:"rawname"`
// Path to the envvar with linenumber
Path string `yaml:"path"`
// FoundInCode indicates if the variable is still found in the codebase.
FoundInCode bool `yaml:"foundincode"`
// Name is equal to RawName but will not be overwritten in consecutive runs
Name string `yaml:"name"`

// These field structs need manual filling:
// Type of the envvar
Type string `yaml:"type"`
// DefaultValue of the envvar
DefaultValue string `yaml:"default_value"`
// Description of what this envvar does
Description string `yaml:"description"`
// Ignore this envvar when creating docs?
Ignore bool `yaml:"do_ignore"`

// For simplicity ignored for now:
// DependendServices []Service `yaml:"dependend_services"`
}
```
This yaml file can later be manually edit to add descriptions, default values, etc.

IMPORTANT: `RawName`, `Path` and `FoundInCode` are automatically filled by the program. DO NOT EDIT THESE VALUES MANUALLY

## Generate Rogue Envvar docs

It picks up the `yaml` file generated in `Extract Rogue Envvars` step and renders it to a adoc file using a go template.

Template for this can be found at `docs/templates/ADOC_global.tmpl`

0 comments on commit ddee772

Please sign in to comment.