You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
generate generates a plugin website from code, templates, and examples
31
+
migrate migrates website files from either the legacy rendered website directory (`website/docs/r`) or the docs rendered website directory (`docs/resources`) to the tfplugindocs supported structure (`templates/`).
31
32
validate validates a plugin website for the current directory
32
33
33
34
```
@@ -59,6 +60,18 @@ $ tfplugindocs validate --help
59
60
Usage: tfplugindocs validate [<args>]
60
61
```
61
62
63
+
`migrate` command:
64
+
65
+
```shell
66
+
$ tfplugindocs migrate --help
67
+
68
+
Usage: tfplugindocs migrate [<args>]
69
+
70
+
--examples-dir <ARG> examples directory based on provider-dir (default: "examples")
71
+
--provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory
72
+
--templates-dir <ARG> new website templates directory based on provider-dir; files will be migrated to this directory (default: "templates")
73
+
```
74
+
62
75
### How it Works
63
76
64
77
When you run `tfplugindocs`, by default from the root directory of a provider codebase, the tool takes the following actions:
@@ -100,6 +113,23 @@ Otherwise, the provider developer can set an arbitrary description like this:
100
113
// ...
101
114
```
102
115
116
+
#### Migrate subcommand
117
+
118
+
The `migrate` subcommand can be used to migrate website files from either the legacy rendered website directory (`website/docs/r`) or the docs
119
+
rendered website directory (`docs/resources`) to the `tfplugindocs` supported structure (`templates/`). Markdown files in the rendered website
120
+
directory will be converted to `tfplugindocs` templates. The legacy `website/` directory will be removed after migration to avoid Terraform Registry
121
+
ingress issues.
122
+
123
+
The `migrate` subcommand takes the following actions:
124
+
1. Determines the rendered website directory based on the `--provider-dir` argument
125
+
2. Copies the contents of the rendered website directory to the `--templates-dir` folder (will create this folder if it doesn't exist)
126
+
3. (if the rendered website is using legacy format) Renames `docs/d/` and `docs/r/` subdirectories to `data-sources/` and `resources/` respectively
127
+
4. Change file suffixes for Markdown files to `.md.tmpl` to create website templates
128
+
5. Extracts code blocks from website docs to create individual example files in `--examples-dir` (will create this folder if it doesn't exist)
129
+
6. Replace extracted example code in website templates with `codefile`/`tffile` template functions referencing the example files.
130
+
7. Copies non-template files to `--templates-dir` folder
131
+
8. Removes the `website/` directory
132
+
103
133
### Conventional Paths
104
134
105
135
The generation of missing documentation is based on a number of assumptions / conventional paths.
@@ -130,6 +160,37 @@ For examples:
130
160
|`examples/resources/<resource name>/resource.tf`| Resource example config |
131
161
|`examples/resources/<resource name>/import.sh`| Resource example import command|
132
162
163
+
#### Migration
164
+
165
+
The `migrate` subcommand assumes the following conventional paths for the rendered website directory:
Files named `index` (before the first `.`) in the website docs root directory and files in the `website/docs/d/`, `website/docs/r/`, `docs/data-sources/`,
188
+
and `docs/resources/` subdirectories will be converted to `tfplugindocs` templates.
189
+
190
+
The `website/docs/guides/` and `docs/guides/` subdirectories will be copied as-is to the `--templates-dir` folder.
191
+
192
+
All other files in the conventional paths will be ignored.
193
+
133
194
### Templates
134
195
135
196
The templates are implemented with Go [`text/template`](https://golang.org/pkg/text/template/)
@@ -179,7 +240,7 @@ using the following data fields and functions:
179
240
|`tffile`| A special case of the `codefile` function, designed for Terraform files (i.e. `.tf`). |
180
241
|`trimspace`| Equivalent to [`strings.TrimSpace`](https://pkg.go.dev/strings#TrimSpace). |
181
242
|`upper`| Equivalent to [`strings.ToUpper`](https://pkg.go.dev/strings#ToUpper). |
182
-
243
+
183
244
## Disclaimer
184
245
185
246
This is still under development: while it's being used for production-ready providers, you might still find bugs
0 commit comments