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

Allow recursive runs to exclude subpaths and/or the top-level path #661

Open
whoracle opened this issue Jan 19, 2023 · 3 comments
Open

Allow recursive runs to exclude subpaths and/or the top-level path #661

whoracle opened this issue Jan 19, 2023 · 3 comments

Comments

@whoracle
Copy link

whoracle commented Jan 19, 2023

What problem are you facing?

We currently have X repositories with Y modules in them (and the modules themselves pull "real" modules via a private module registry in gitlab). I want to force README generation in each module via pre-commit, but I want to leave the repo root README alone (since there's no tf files in there anyways), but I only want to have one unified terraform-docs.yml in each repository.

Currently, if I run terraform-docs -c .terraform-docs.yml . in the repo root, my main README gets modified alongside the module README files. If I start one level deeper with e.g. terraform-docs -c .terraform-docs.yml subscriptions, then I get a README in subscriptions, which I also don't want.

Example repo structure:

~/terraform/azure
├───subscriptions
│       │
│       ├───my_dev_sub
│       │        ├───main.tf
│       │        ├───more_files.tf
│       │        ├───terragrunt.hcl
│       │        └───README.md
│       │
│       ├───my_staging_sub
│       │        ├───main.tf
│       │        ├───more_files.tf
│       │        ├───terragrunt.hcl
│       │        └───README.md
│       │
│       └───my_prod_sub
│                ├───main.tf
│                ├───more_files.tf
│                ├───terragrunt.hcl
│                └───README.md
|
├───.terraform-docs.yml
├───terragrunt.hcl
└───README.md

How could terraform-docs help solve your problem?

I have two ideas for a solution:

  • Let me specify which folders to exclude in .terraform-docs.yml in the recursive tree or a global .terraform-docs-ignore file in the repo root
  • make terraform-docs ignore all directories that contain a .terraform-docs-ignore file in them (can be empty)
    For my specific use case I don't have a strong preference either way, since I only want to exclude a single location (the top level), but a more flexible approach would maybe be advised for people who want to ignore more than one path.

Kind Regards

@kraduk
Copy link

kraduk commented Apr 6, 2023

sub optimal, but just .gitignore those files

@rob-borg
Copy link

rob-borg commented Sep 8, 2023

As an addition I would like to specify which submodules to exclude from doc generation completely during a recursive generation

@martin-reich
Copy link

martin-reich commented Feb 8, 2024

As mentioned in #613:
You can use a workaround:

terraform-docs markdown --output-mode replace --output-file README.md --recursive --recursive-path ../ ./modules/name-of-module

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants