GithubHelp home page GithubHelp logo

isabella232 / terraform-plugin-docs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hashicorp/terraform-plugin-docs

0.0 0.0 0.0 125 KB

Generate and validate Terraform plugin/provider documentation.

License: Mozilla Public License 2.0

Go 100.00%

terraform-plugin-docs's Introduction

terraform-plugin-docs

This repository contains tools and packages for creating Terraform plugin docs (currently only provider plugins). The primary way users will interact with this is the tfplugindocs CLI tool to generate and validate plugin documentation.

tfplugindocs

The tfplugindocs CLI has two main commands, validate and generate (generate is the default). This tool will let you generate documentation for your provider from live example .tf files and markdown templates. It will also export schema information from the provider (using terraform providers schema -json), and sync the schema with the reference documents. If your documentation only consists of simple examples and schema information, the tool can also generate missing template files to make website creation extremely simple for most providers.

How it Works

When you run tfplugindocs from root directory of the provider the tool takes the following actions:

  • Copy all the templates and static files to a temporary directory
  • Build (go build) a temporary binary of the provider source code
  • Collect schema information using terraform providers schema -json
  • Generate a default provider template file, if missing (index.md)
  • Generate resource template files, if missing
  • Generate data source template files, if missing
  • Copy all non-template files to the output website directory
  • Process all the remaining templates to generate files for the output website directory

You can see an example of the templates and output in paultyng/terraform-provider-unifi and browse the generated docs in the Terraform Registry.

Conventional Paths

The generation of missing documentation is based on a number of assumptions / conventional paths:

Path Description
templates/ Root of templated docs
templates/index.md[.tmpl] Docs index page (or template)
examples/provider/provider.tf Provider example config*
templates/data-sources/<data source name>.md[.tmpl] Data source page (or template)
examples/data-sources/<data source name>/data-source.tf Data source example config*
templates/resources/<resource name>.md[.tmpl] Resource page (or template)
examples/resources/<resource name>/resource.tf Resource example config*
examples/resources/<resource name>/import.sh Resource example import command

Templates

The templates are implemented with Go text/template using the following objects and functions:

Template Objects

TBD

Template Functions

Function Description
codefile Create a Markdown code block and populate it with the contents of a file. Path is relative to the repository root.
tffile A special case of the codefile function. In addition this will elide lines with an OMIT comment.
trimspace strings.TrimSpace
plainmarkdown Render Markdown content as plaintext

Installation

You can install a copy of the binary manually from the releases, or you can optionally use the tools.go model for tool installation.

Disclaimer

This experimental repository contains software which is still being developed and in the alpha testing stage. It is not ready for production use.

terraform-plugin-docs's People

Contributors

gdavison avatar koikonom avatar paultyng avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.