https://github.com/projectdiscovery/yamldoc-go
A documentation generator for YAML as code
https://github.com/projectdiscovery/yamldoc-go
Last synced: over 1 year ago
JSON representation
A documentation generator for YAML as code
- Host: GitHub
- URL: https://github.com/projectdiscovery/yamldoc-go
- Owner: projectdiscovery
- License: mit
- Created: 2021-05-06T20:05:09.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-31T00:18:36.000Z (over 1 year ago)
- Last Synced: 2025-03-31T11:04:39.529Z (over 1 year ago)
- Language: Go
- Size: 102 KB
- Stars: 21
- Watchers: 13
- Forks: 4
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# yamldoc-go
A standalone version of the YAML Code Documentation approach described at https://www.talos-systems.com/blog/documentation-as-code/. All credits goes to original authors.
### Changes
- Added support for example name based comments
- Fixed a panic with embedded structs and added support for them.
- Complete rewrite of docgen using [dst](https://github.com/dave/dst) to support multi-package structure organization.
### Usage
The general recommendation is, all the structures for a single type should be in a single file.
The following go:generate command will generate docs for a specified file.
```bash
//go:generate dstdocgen -path ~/projectdiscovery/nuclei/v2/pkg/templates -structure Template -output output.go
$ go generate pkg/.go
```
Below is an example struct with all supported annotation as examples.
```go
kubeletExtraMountsExample = []specs.Mount{
{
Source: "/var/lib/example",
Destination: "/var/lib/example",
Type: "bind",
Options: []string{
"rshared",
"rw",
},
},
}
...
type Config struct {
// description: |
// Indicates the schema used to decode the contents.
// values:
// - v1alpha1
ConfigVersion string `yaml:"version"`
// description: |
// Enable verbose logging.
// values:
// - true
// - yes
// - false
// - no
ConfigDebug bool `yaml:"debug"`
// description: |
// The `image` field is an optional reference to an alternative kubelet image.
// examples:
// - value: '"docker.io//kubelet:latest"'
KubeletImage string `yaml:"image,omitempty"`
// description: |
// The `extraArgs` field is used to provide additional flags to the kubelet.
// examples:
// - name: Description for this example
// value: >
// map[string]string{
// "key": "value",
// }
KubeletExtraArgs map[string]string `yaml:"extraArgs,omitempty"`
// description: |
// The `extraMounts` field is used to add additional mounts to the kubelet container.
// examples:
// - value: kubeletExtraMountsExample
KubeletExtraMounts []specs.Mount `yaml:"extraMounts,omitempty"`
}
```