Khosrow Moossavi 6534330b66 Add support for rendering Markdown documents (#81)
* Add support for rendering Markdown content

* Change --markdown-table and --markdown-document flags to corresponding subcommands

* Use import aliases for 'markdown' packages

* Keep functions in alphabetic order

* Remove redundant 'showDefault' variable

* Prettify list and map for 'markdown document' view

* Rename package from 'content' to 'document'

* Fix some wording in README and Usage text

* Improve documentation.

* Improve wording around inputs and outputs.

* Improve code readability and maintainability.

* Rename misnamed function 'printMarkdown' to 'printInput'.

* Remove remark 'optional' from markdown types documentation.

* Refactor fenced code block generation.

* Add JSON language specifier to fenced code block generation.

* Add Markdown document sanitising to soothe linters.

* Minor code beautification.

* Fix gometalinter error
2018-12-02 09:22:57 +01:00
2018-10-24 18:51:41 +02:00
2017-10-22 17:11:06 +03:00
2018-10-24 18:51:41 +02:00

terraform-docs

CircleCI

A utility to generate documentation from Terraform modules.

screen shot 2016-06-14 at 5 38 37 pm

Maintenance

This project is no longer maintained by Segment. Instead, Martin Etmajer, unaffiliated with Segment, from GetCloudnative, is maintaining the project with help from these awesome contributors.

Features

  • View docs for inputs and outputs
  • Generate docs for inputs and outputs
  • Generate JSON docs (for customizing presentation)
  • Generate markdown tables of inputs and outputs
  • Generate markdown document of inputs and outputs

Installation

  • go get github.com/segmentio/terraform-docs
  • Binaries
  • brew install terraform-docs (on macOS)

Usage


  Usage:
    terraform-docs [--no-required] [--no-sort | --sort-inputs-by-required] [--with-aggregate-type-defaults] [json | markdown | md] [document | table] <path>...
    terraform-docs -h | --help

  Examples:

    # View inputs and outputs
    $ terraform-docs ./my-module

    # View inputs and outputs for variables.tf and outputs.tf only
    $ terraform-docs variables.tf outputs.tf

    # Generate a JSON of inputs and outputs
    $ terraform-docs json ./my-module

    # Generate markdown tables of inputs and outputs
    $ terraform-docs md ./my-module

    # Generate markdown tables of inputs and outputs
    $ terraform-docs md table ./my-module

    # Generate markdown document of inputs and outputs
    $ terraform-docs md document ./my-module

    # Generate markdown tables of inputs and outputs for the given module and ../config.tf
    $ terraform-docs md ./my-module ../config.tf

  Options:
    -h, --help                       show help information
    --no-required                    omit "Required" column when generating markdown
    --no-sort                        omit sorted rendering of inputs and ouputs
    --sort-inputs-by-required        sort inputs by name and prints required inputs first
    --with-aggregate-type-defaults   print default values of aggregate types
    --version                        print version

  Types of markdown:
    document                         generate markdown document of inputs and outputs
    table                            generate markdown tables of inputs and outputs (default)

Example

Given a simple module at ./_example:

/**
 * This module has a variable and an output.  This text here will be output before any inputs or outputs!
 */

variable "subnet_ids" {
  description = "a comma-separated list of subnet IDs"
}

// The VPC ID.
output "vpc_id" {
  value = "vpc-5c1f55fd"
}

To view docs:

$ terraform-docs _example

To output JSON docs:

$ terraform-docs json _example
{
  "Comment": "This module has a variable and an output.  This text here will be output before any inputs or outputs!\n",
  "Inputs": [
    {
      "Name": "subnet_ids",
      "Description": "a comma-separated list of subnet IDs",
      "Default": ""
    }
  ],
  "Outputs": [
    {
      "Name": "vpc_id",
      "Description": "The VPC ID.\n"
    }
  ]
}

To output markdown tables (Note: underscores are escaped in markdown output):

$ terraform-docs md table _example
This module has a variable and an output.  This text here will be output before any inputs or outputs!


## Inputs

| Name | Description | Type |Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| subnet\_ids | a comma-separated list of subnet IDs | string | - | yes |

## Outputs

| Name | Description |
|------|-------------|
| vpc\_id | The VPC ID. |

To output markdown document (Note: underscores are escaped in markdown output):

$ terraform-docs md document _example
This module has a variable and an output.  This text here will be output before any inputs or outputs!


## Required Inputs

The following input variables are required:

### subnet\_ids

Description: a comma-separated list of subnet IDs

Type: `string`

## Outputs

The following outputs are exported:

### vpc\_id

Description: The VPC ID.

License

MIT License

Copyright (c) 2018 The terraform-docs Authors.

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.

Languages
Go 98.3%
Makefile 1.2%
Dockerfile 0.3%
Shell 0.2%