This commit is contained in:
Amir Abushareb
2016-06-13 11:43:31 +02:00
parent 5b64ac79bf
commit a37fbf9264
3 changed files with 110 additions and 4 deletions

99
Readme.md Normal file
View File

@@ -0,0 +1,99 @@
`tf-docs(1)` ⋅ a quick utility to generate markdown docs.
## Features
- Generate docs for inputs and outputs
- Generate JSON docs (for customizing presentation)
- Generate markdown tables of inputs and outputs
## Usage
```bash
Usage:
tf-docs <dir>
tf-docs md <dir>
tf-docs -h | --help
Examples:
# Generate a JSON of inputs and outputs
$ tf-docs ./my-module
# Generate markdown tables of inputs and outputs
$ tf-docs md ./my-module
Options:
-h, --help show help information
```
## Example
Given a simple module at `./_example`:
```terraform
variable "subnet_ids" {
description = "a comma-separated list of subnet IDs"
}
// The VPC ID.
output "vpc_id" {
value = ""
}
```
To output JSON docs:
```bash
$ tf-docs _example
[
{
"Type": "input",
"Name": "subnet_ids",
"Value": "",
"Default": "",
"Description": "a comma-separated list of subnet IDs"
},
{
"Type": "output",
"Name": "vpc_id",
"Value": "\"\"",
"Default": "",
"Description": "The VPC ID.\n"
}
]
```
To output markdown docs:
```bash
$ tf-docs md _example
## Inputs
| Name | Description | Default | Required |
|------|-------------|:-----:|:-----:|
| subnet_ids | a comma-separated list of subnet IDs | - | yes |
## Outputs
| Name | Description |
|------|-------------|
| vpc_id | The VPC ID. |
```
## License
Released under the MIT License
(The MIT License)
Copyright (c) 2016 Segment friends@segment.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

9
_example/main.tf Normal file
View File

@@ -0,0 +1,9 @@
variable "subnet_ids" {
description = "a comma-separated list of subnet IDs"
}
// The VPC ID.
output "vpc_id" {
value = "vpc-5c1f55fd"
}

View File

@@ -20,7 +20,6 @@ const usage = `
tf-docs <dir>
tf-docs md <dir>
tf-docs -h | --help
tf-docs -v | --version
Examples:
@@ -31,13 +30,12 @@ const usage = `
$ tf-docs md ./my-module
Options:
-h, --help show help information
-v, --version show version information
-h, --help show help information
`
func main() {
args, err := docopt.Parse(usage, nil, true, version, false)
args, err := docopt.Parse(usage, nil, true, version, true)
if err != nil {
log.Fatal(err)
}