-
Notifications
You must be signed in to change notification settings - Fork 77
Implement migrate sub-command
#314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
3e86e3a
5168362
6cc8db5
cc4b712
952eaff
9d76267
a67b696
fd96f85
5240d47
ae83428
32170f3
fcc2b0b
c608fd9
14d65a6
ecbdd11
02f970e
d687f35
84a9af4
b9d1018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| kind: FEATURES | ||
| body: adds new `migrate` subcommand migrates that existing provider docs using the | ||
| old website directory structure (`website/docs/`) to a `terraform-plugin-docs`-supported | ||
| templates directory. | ||
| time: 2023-12-20T14:12:44.820323-05:00 | ||
| custom: | ||
| Issue: "314" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -59,6 +59,19 @@ $ tfplugindocs validate --help | |
| Usage: tfplugindocs validate [<args>] | ||
| ``` | ||
|
|
||
| `migrate` command: | ||
|
|
||
| ```shell | ||
| $ tfplugindocs migrate --help | ||
|
|
||
| Usage: tfplugindocs migrate [<args>] | ||
|
|
||
| --examples-dir <ARG> examples directory based on provider-dir (default: "examples") | ||
| --old-website-source-dir <ARG> old website directory based on provider-dir; files will be migrated from this directory (default: "website") | ||
| --provider-dir <ARG> relative or absolute path to the root provider code directory when running the command outside the root provider code directory | ||
| --templates-dir <ARG> new website templates directory based on provider-dir; files will be migrated to this directory (default: "templates") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At first glance, it wasn't immediately obvious what the input directories were vs. the output directory without reading the help text. Would it be confusing/misleading to name the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the name should be the same to keep it in parity with the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah okay that's helpful context! Makes sense to me 👍🏻 |
||
| ``` | ||
|
|
||
| ### How it Works | ||
|
|
||
| When you run `tfplugindocs`, by default from the root directory of a provider codebase, the tool takes the following actions: | ||
|
|
@@ -100,6 +113,18 @@ Otherwise, the provider developer can set an arbitrary description like this: | |
| // ... | ||
| ``` | ||
|
|
||
| #### Migrate subcommand | ||
|
|
||
| The `migrate` subcommand can be used to migrate from the old directory structure (`website/docs/r`) to the `tfplugindocs` supported structure (`templates/`). | ||
|
|
||
| The `migrate` subcommand takes the following actions: | ||
|
SBGoods marked this conversation as resolved.
|
||
| - Copies the `--old-website-source-dir` folder to the `--tempates-dir` folder (will create this folder if it doesn't exist) | ||
| - Renames `docs/d/` and `docs/r/` subdirectories to `data-sources/` and `resources/` respectively | ||
| - Change file suffixes for template files from `.html.markdown` to `.md.tmpl` | ||
| - Extracts code blocks from website docs to create individual example files in `--examples-dir` (will create this folder if it doesn't exist) | ||
| - replace extracted example code in website templates with `tfplugindocs` template code referring to example files. | ||
|
SBGoods marked this conversation as resolved.
Outdated
|
||
| - Copies non-template files to `--templates-dir` folder | ||
|
|
||
| ### Conventional Paths | ||
|
|
||
| The generation of missing documentation is based on a number of assumptions / conventional paths. | ||
|
|
@@ -130,6 +155,17 @@ For examples: | |
| | `examples/resources/<resource name>/resource.tf` | Resource example config | | ||
| | `examples/resources/<resource name>/import.sh` | Resource example import command | | ||
|
|
||
| #### Migration | ||
|
|
||
| The `migrate` subcommand assumes the following conventional paths for the old website structure: | ||
|
|
||
| | Path | Description | | ||
| |---------------------------------------------------|----------------------| | ||
| | `website/` | Root of website docs | | ||
| | `website/docs/index.html.markdown` | Docs index page | | ||
| | `website/docs/d/<data source name>.html.markdown` | Data source page | | ||
| | `website/docs/r/<resource name>.html.markdown` | Resource page | | ||
|
SBGoods marked this conversation as resolved.
Outdated
|
||
|
|
||
| ### Templates | ||
|
|
||
| The templates are implemented with Go [`text/template`](https://golang.org/pkg/text/template/) | ||
|
|
@@ -179,7 +215,7 @@ using the following data fields and functions: | |
| | `tffile` | A special case of the `codefile` function, designed for Terraform files (i.e. `.tf`). | | ||
| | `trimspace` | Equivalent to [`strings.TrimSpace`](https://pkg.go.dev/strings#TrimSpace). | | ||
| | `upper` | Equivalent to [`strings.ToUpper`](https://pkg.go.dev/strings#ToUpper). | | ||
|
|
||
| ## Disclaimer | ||
|
|
||
| This is still under development: while it's being used for production-ready providers, you might still find bugs | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.