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
body: 'validate: Add `allowed-guide-subcategories-file` and `allowed-resource-subcategories-file` to provide a file containing a list of allowed subcategories'
Copy file name to clipboardExpand all lines: README.md
+33-29Lines changed: 33 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,7 +53,7 @@ Available commands are:
53
53
generate generates a plugin website from code, templates, and examples
54
54
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/`).
--examples-dir <ARG> examples directory based on provider-dir (default: "examples")
67
67
--ignore-deprecated <ARG> don't generate documentation for deprecated resources and data-sources (default: "false")
68
-
--provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory
69
-
--provider-name <ARG> provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)
70
-
--providers-schema <ARG> path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI
71
-
--rendered-provider-name <ARG> provider name, as generated in documentation (ex. page titles, ...)
68
+
--provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory
69
+
--provider-name <ARG> provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)
70
+
--providers-schema <ARG> path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI
71
+
--rendered-provider-name <ARG> provider name, as generated in documentation (ex. page titles, ...)
72
72
--rendered-website-dir <ARG> output directory based on provider-dir (default: "docs")
73
-
--tf-version <ARG> terraform binary version to download. If not provided, will look for a terraform binary in the local environment. If not found in the environment, will download the latest version of Terraform
73
+
--tf-version <ARG> terraform binary version to download. If not provided, will look for a terraform binary in the local environment. If not found in the environment, will download the latest version of Terraform
74
74
--website-source-dir <ARG> templates directory based on provider-dir (default: "templates")
75
-
--website-temp-dir <ARG> temporary directory (used during generation)
75
+
--website-temp-dir <ARG> temporary directory (used during generation)
--provider-dir <ARG> relative or absolute path to the root provider code directory; this will default to the current working directory if not set
86
-
--provider-name <ARG> provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)
87
-
--providers-schema <ARG> path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI
88
-
--tf-version <ARG> terraform binary version to download. If not provided, will look for a terraform binary in the local environment. If not found in the environment, will download the latest version of Terraform
85
+
--allowed-guide-subcategories <ARG> comma separated list of allowed guide frontmatter subcategories
86
+
--allowed-guide-subcategories-file <ARG> path to newline separated file of allowed guide frontmatter subcategories
87
+
--allowed-resource-subcategories <ARG> comma separated list of allowed resource frontmatter subcategories
88
+
--allowed-resource-subcategories-file <ARG> path to newline separated file of allowed resource frontmatter subcategories
89
+
--provider-dir <ARG> relative or absolute path to the root provider code directory; this will default to the current working directory if not set
90
+
--provider-name <ARG> provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)
91
+
--providers-schema <ARG> path to the providers schema JSON file, which contains the output of the terraform providers schema -json command. Setting this flag will skip building the provider and calling Terraform CLI
92
+
--tf-version <ARG> terraform binary version to download. If not provided, will look for a terraform binary in the local environment. If not found in the environment, will download the latest version of Terraform
--examples-dir <ARG> examples directory based on provider-dir (default: "examples")
99
103
--provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory
100
104
--templates-dir <ARG> new website templates directory based on provider-dir; files will be migrated to this directory (default: "templates")
101
-
--provider-name <ARG> provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)
105
+
--provider-name <ARG> provider name, as used in Terraform configurations; defaults to the --provider-dir short name (after removing `terraform-provider-` prefix)
102
106
```
103
107
104
108
### How it Works
@@ -161,22 +165,22 @@ Otherwise, the provider developer can set an arbitrary description like this:
161
165
162
166
The `validate` subcommand can be used to validate the provider website documentation against the [Terraform Registry's provider documentation guidelines](https://developer.hashicorp.com/terraform/registry/providers/docs) and provider documentation best practices. The current checks in the `validate` command are:
| `InvalidDirectoriesCheck` | Checks for valid subdirectory structure and throws an error if an invalid Terraform Provider documentation subdirectory is found. |
167
-
| `MixedDirectoriesCheck` | Throws an error if both legacy documentation (`/website/docs`) and registry documentation (`/docs`) are found. |
168
-
| `FileSizeCheck` | Throws an error if the documentation file is above the registry storage limit. |
169
-
| `FileExtensionCheck` | Throws an error if the extension of the given file is not a valid registry documentation extension. |
170
-
| `FrontMatterCheck` | Checks the YAML frontmatter of documentation for missing required fields or invalid fields. |
171
-
| `FileMismatchCheck` | Throws an error if the names/number of resources/datasources/functions in the provider schema does not match the names/number of files in the corresponding documentation directory |
| `InvalidDirectoriesCheck` | Checks for valid subdirectory structure and throws an error if an invalid Terraform Provider documentation subdirectory is found. |
171
+
| `MixedDirectoriesCheck` | Throws an error if both legacy documentation (`/website/docs`) and registry documentation (`/docs`) are found. |
172
+
| `FileSizeCheck` | Throws an error if the documentation file is above the registry storage limit. |
173
+
| `FileExtensionCheck` | Throws an error if the extension of the given file is not a valid registry documentation extension. |
174
+
| `FrontMatterCheck` | Checks the YAML frontmatter of documentation for missing required fields or invalid fields. Optionally, checks that the `subcategory` is within the specified allow list. |
175
+
| `FileMismatchCheck` | Throws an error if the names/number of resources/datasources/functions in the provider schema does not match the names/number of files in the corresponding documentation directory. |
172
176
173
177
All check errors are wrapped and returned as a single error message to stderr.
174
178
175
179
#### Migrate subcommand
176
180
177
-
The `migrate` subcommand can be used to migrate website files from either the legacy rendered website directory (`website/docs/r`) or the docs
178
-
rendered website directory (`docs/resources`) to the `tfplugindocs` supported structure (`templates/`). Markdown files in the rendered website
179
-
directory will be converted to `tfplugindocs` templates. The legacy `website/` directory will be removed after migration to avoid Terraform Registry
181
+
The `migrate` subcommand can be used to migrate website files from either the legacy rendered website directory (`website/docs/r`) or the docs
182
+
rendered website directory (`docs/resources`) to the `tfplugindocs` supported structure (`templates/`). Markdown files in the rendered website
183
+
directory will be converted to `tfplugindocs` templates. The legacy `website/` directory will be removed after migration to avoid Terraform Registry
180
184
ingress issues.
181
185
182
186
The `migrate` subcommand takes the following actions:
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/`,
264
-
and `docs/resources/` subdirectories will be converted to `tfplugindocs` templates.
267
+
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/`,
268
+
and `docs/resources/` subdirectories will be converted to `tfplugindocs` templates.
265
269
266
-
The `website/docs/guides/` and `docs/guides/` subdirectories will be copied as-is to the `--templates-dir` folder.
270
+
The `website/docs/guides/` and `docs/guides/` subdirectories will be copied as-is to the `--templates-dir` folder.
267
271
268
272
All other files in the conventional paths will be ignored.
269
273
@@ -356,13 +360,13 @@ This repo uses the `testscript` [package](https://pkg.go.dev/github.com/rogpeppe
356
360
357
361
There are two types of acceptance tests: full provider build tests in`tfplugindocs/testdata/scripts/provider-build` and provider schema json tests in`tfplugindocs/testdata/scripts/schema-json`.
358
362
359
-
Provider build tests run the default `tfplugindocs`command which builds the provider source code and runs Terraform to retrieve the schema. These tests require the full provider source code to build a valid provider binary.
363
+
Provider build tests run the default `tfplugindocs`command which builds the provider source code and runs Terraform to retrieve the schema. These tests require the full provider source code to build a valid provider binary.
360
364
361
-
Schema json tests run the `tfplugindocs`command with the `--providers-schema=<arg>` flag to specify a provider schemas json file. This allows the test to skip the provider build and Terraform CLI call, instead using the specified file to generate docs.
365
+
Schema json tests run the `tfplugindocs`command with the `--providers-schema=<arg>` flag to specify a provider schemas json file. This allows the test to skip the provider build and Terraform CLI call, instead using the specified file to generate docs.
362
366
363
367
You can run `make testacc` to run the full suite of acceptance tests. By default, the provider build acceptance tests will create a temporary directory in`/tmp/tftmp`fortesting, but you can change this locationin`cmd/tfplugindocs/main_test.go`. The schema json tests uses the `testscript` package's [default work directory](https://pkg.go.dev/github.com/rogpeppe/go-internal/testscript#Params.WorkdirRoot).
364
368
365
369
The test scripts are defined in the `tfplugindocs/testdata/scripts` directory. Each script includes the test, golden files, and the provider source code or schema JSON file needed to run the test.
366
370
367
-
Each script is a [text archive](https://pkg.go.dev/golang.org/x/tools/txtar). You can install the `txtar` CLI locally by running `go install golang.org/x/exp/cmd/txtar@latest` to extract the files in the test script for debugging.
371
+
Each script is a [text archive](https://pkg.go.dev/golang.org/x/tools/txtar). You can install the `txtar` CLI locally by running `go install golang.org/x/exp/cmd/txtar@latest` to extract the files in the test script for debugging.
368
372
You can also use `txtar` CLI archive files into the `.txtar` format to create new tests or modify existing ones.
0 commit comments