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
Member

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
Member

@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
@SBGoods SBGoods merged commit 93aa7d3 into main Jul 6, 2023
5 checks passed
@SBGoods SBGoods deleted the SBGoods/skip-subdir branch July 6, 2023 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants