|
| 1 | +/* |
| 2 | +Copyright 2021 The terraform-docs Authors. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package engine |
| 18 | + |
| 19 | +const ( |
| 20 | + tplHeader = ` |
| 21 | + {{- if .Settings.ShowHeader -}} |
| 22 | + {{- with .Module.Header -}} |
| 23 | + {{ . }} |
| 24 | + {{ printf "\n" }} |
| 25 | + {{- end -}} |
| 26 | + {{ end -}} |
| 27 | + ` |
| 28 | + |
| 29 | + tplInputs = ` |
| 30 | + {{- if .Settings.ShowInputs -}} |
| 31 | + {{ indent 0 "#" }} Inputs |
| 32 | + {{ if not .Module.Inputs }} |
| 33 | + No inputs. |
| 34 | + {{ else }} |
| 35 | + {{- range .Module.Inputs }} |
| 36 | + {{ printf "\n" }} |
| 37 | + {{ indent 1 "#" }} {{ name .Name }} ` + "`" + `{{ .Type }}` + "`" + ` |
| 38 | +
|
| 39 | + Description: {{ .Description }} |
| 40 | + Default: {{ .Default }} |
| 41 | + {{- end }} |
| 42 | + {{ end }} |
| 43 | + {{ end -}} |
| 44 | + ` |
| 45 | + |
| 46 | + tplOutputs = ` |
| 47 | + {{- if .Settings.ShowOutputs -}} |
| 48 | + {{ indent 0 "#" }} Outputs |
| 49 | + {{ if not .Module.Outputs }} |
| 50 | + No outputs. |
| 51 | + {{ else }} |
| 52 | + | Name | Description | Type | Default | |
| 53 | + |------|-------------|------|---------| |
| 54 | + {{- range .Module.Outputs }} |
| 55 | + - {{ .Name }} |
| 56 | + - {{ .Description }} |
| 57 | + {{- end }} |
| 58 | + {{ end }} |
| 59 | + {{ end -}} |
| 60 | + ` |
| 61 | + |
| 62 | + tplRequirements = ` |
| 63 | + {{- if .Settings.ShowRequirements -}} |
| 64 | + {{ indent 0 "#" }} Requirements |
| 65 | + |
| 66 | + Intentionally don't show requirements to demonstrate the flexibility of the plugin. |
| 67 | + {{ end -}} |
| 68 | + ` |
| 69 | + |
| 70 | + tplResources = ` |
| 71 | + {{- if .Settings.ShowResources -}} |
| 72 | + {{ indent 0 "#" }} Resources |
| 73 | + {{ if not .Module.Resources }} |
| 74 | + No resources. |
| 75 | + {{ else }} |
| 76 | + {{- range .Module.Resources }} |
| 77 | + - {{ .Name }} |
| 78 | + {{- end }} |
| 79 | + {{- end }} |
| 80 | + {{ end -}} |
| 81 | + ` |
| 82 | + |
| 83 | + tplProviders = ` |
| 84 | + {{- if .Settings.ShowProviders -}} |
| 85 | + {{ indent 0 "#" }} Providers |
| 86 | + {{ if not .Module.Providers }} |
| 87 | + No providers. |
| 88 | + {{ else }} |
| 89 | + {{- range .Module.Providers }} |
| 90 | + - {{ .ProviderName }} |
| 91 | + {{- end }} |
| 92 | + {{- end }} |
| 93 | + {{ end -}} |
| 94 | + ` |
| 95 | + |
| 96 | + tplCustom = ` |
| 97 | + {{- template "header" . -}} |
| 98 | + {{- template "inputs" . -}} |
| 99 | + {{- template "outputs" . -}} |
| 100 | + {{- template "requirements" . -}} |
| 101 | + {{- template "providers" . -}} |
| 102 | + {{- template "resources" . -}} |
| 103 | + ` |
| 104 | +) |
0 commit comments