Skip to content
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

generate: Remove only tfplugindocs managed files and subdirectories from rendered website directory #267

Merged
merged 9 commits into from
Jul 6, 2023

Conversation

SBGoods
Copy link
Contributor

@SBGoods SBGoods commented Jun 29, 2023

Relates: hashicorp/terraform-provider-null#218

Previously, tfplugindocs would remove the rendered website directory and all subdirectories if they exist before generating new website documentation. This method prevents documentation not managed by tfplugindocs to coexist in the website directory. This change modifies the generation to only remove subdirectories and files directly managed by the tool including: "data-sources", "guides", "resources", and "index.md".

Due to the lack of existing end-to-end testing, this was verified by locally compiling and running against a branch of terraform-provider-null which had a cdktf subdirectory within docs. Running the command excludes the cdktf subdirectory from deletion while still generating documentation from the templates and examples as expected.

$ ./tfplugindocs generate
rendering website for provider "terraform-provider-null" (as "terraform-provider-null")
copying any existing content to tmp dir
exporting schema from Terraform
compiling provider "null"
using Terraform CLI binary from PATH if available, otherwise downloading latest Terraform CLI binary
running terraform init
getting provider schema
rendering missing docs
generating missing resource content
resource "null_resource" fallback template exists
generating template for "null_resource"
generating missing data source content
resource "null_data_source" fallback template exists
generating template for "null_data_source"
generating missing provider content
provider "terraform-provider-null" template exists, skipping
rendering static website
cleaning rendered website dir
removing directory: "data-sources"
removing file: "index.md"
removing directory: "resources"
rendering templated website to static markdown
rendering "data-sources/data_source.md.tmpl"
rendering "index.md.tmpl"
rendering "resources/resource.md.tmpl"

@SBGoods SBGoods requested a review from a team as a code owner June 29, 2023 18:35
@bflad
Copy link
Contributor

bflad commented Jul 3, 2023

Hey @SBGoods 👋 Definitely 👍 on handling this somehow, but I'm a little curious about two mutually exclusive ideas here:

  • Should cdktf be automatically excluded so folks do not need to discover or figure out the exclusion flag? Since CDKTF documentation is intended to be a "first class" provider documentation feature, I think it might be worth giving it special handling out of the box.
  • Should the directory deletion be limited to "known" directories instead of deleting all other directories? I think this might overall a better behavior for the generator rather than assuming full control over the docs/ directory contents and requiring folks to figure out exclusion rules, etc.

@SBGoods SBGoods changed the title generate: introduce exclude-rendered-website-sub-dir flag generate: Remove only tfplugindocs managed files and subdirectories from rendered website directory Jul 5, 2023
@SBGoods SBGoods requested a review from bflad July 5, 2023 20:08
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 🚀

internal/provider/validate.go Show resolved Hide resolved
@bflad bflad added the enhancement New feature or request label Jul 6, 2023
@bflad bflad added this to the v0.16.0 milestone Jul 6, 2023
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants