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

When using recursive: true allow skipping changes to root README.md #613

Open
sysadmiral opened this issue May 17, 2022 · 9 comments · May be fixed by #621
Open

When using recursive: true allow skipping changes to root README.md #613

sysadmiral opened this issue May 17, 2022 · 9 comments · May be fixed by #621

Comments

@sysadmiral
Copy link

What problem are you facing?

When working in a repository used purely for modules it would be useful to be able to skip changes to the root README.md.

Since all of the modules are in subdirectories we only want to update the README in the subdirectory and not the root (which has no terraform code).

Currently when you run terraform-docs in recursive mode it generates the submodule docs correctly but also adds to the root README which makes no sense in this scenario.

How could terraform-docs help solve your problem?

Possibly add skip-root-readme as an option:

recursive:
  enabled: true
  path: modules
  skip-root-readme: true
@aashery-square
Copy link

@blakegong any update on the fix?

@deeparavirdc
Copy link

Any update on this or a workaround to skip root README from being updated ?

@nosrio
Copy link

nosrio commented Feb 10, 2023

Hi! Any updates on this?

@ashleyghooper
Copy link

Could one of the project maintainers please review @blakegong 's pull request?

@armsnyder
Copy link

I'm working around this issue for now by using the hide-empty setting. It works as long as you don't have Terraform files in the root, and you're ok with hiding empty sections.

output:
  file: README.md
  mode: inject
  template: |-
    <!-- BEGIN_TF_DOCS -->
    {{ .Content }}
    <!-- END_TF_DOCS -->
settings:
  hide-empty: true

@riemers
Copy link

riemers commented May 9, 2023

@metmajer , @khos2ow can any of you guys press the merge button? Looks like a minor thing and bumped into this issue too. Just pinging since its open since 2022, might have dropped of the radar ;)

@OlesYudin
Copy link

OlesYudin commented May 25, 2023

I'm working around this issue for now by using the hide-empty setting. It works as long as you don't have Terraform files in the root, and you're ok with hiding empty sections.

output:
  file: README.md
  mode: inject
  template: |-
    <!-- BEGIN_TF_DOCS -->
    {{ .Content }}
    <!-- END_TF_DOCS -->
settings:
  hide-empty: true

For me, it's not work:(
It still generates an empty .md file only with a comment block.
Something like this

<!-- BEGIN_TF_DOCS -->
<!-- END_TF_DOCS -->

Also, I've tried to add empty .md files to .gitignore but it's still generating files:(

Example:

.gitignore file
# Ignore empty TF-DOC.md files
TF-DOC.tf
./modules/TF-DOC.tf

@martin-reich
Copy link

martin-reich commented Feb 8, 2024

As the PR does not seem to get merged, you can meanwhile use a workaround:

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

@AidasPasilisVinted
Copy link

AidasPasilisVinted commented Mar 12, 2024

The following args work for me:
args: ["markdown", "table", "--output-mode", "replace", "--output-file", "README.md", "--recursive", "./modules", "--recursive-path", "."]

I had a problem where terraform-docs were modifying the root README of my repository. The above args fixed the issue for me.

Just as an FYI, my repo structure:

  • ...
  • modules/
  • README.md

now terraform-docs only updates readme files in modules/ and all modules/, but not the root of the repository.

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

Successfully merging a pull request may close this issue.

10 participants