diff --git a/docs/user-guide/configuration.md b/docs/user-guide/configuration.md index 89a186c..085739c 100644 --- a/docs/user-guide/configuration.md +++ b/docs/user-guide/configuration.md @@ -39,10 +39,13 @@ $ tree $ terraform-docs -c .tfdocs-config.yml . ``` -As of `v0.13.0`, the order for looking for config file is: +As of `v0.13.0`, the order for looking for config file is *(2 and 4 were added +in `v0.15.0`)*: 1. root of module directory +1. `.config/` folder at root of module directory 1. current directory +1. `.config/` folder at current directory 1. `$HOME/.tfdocs.d/` if `.terraform-docs.yml` is found in any of the folders above, that will take diff --git a/internal/cli/run.go b/internal/cli/run.go index 46d7277..e2397a0 100644 --- a/internal/cli/run.go +++ b/internal/cli/run.go @@ -61,9 +61,11 @@ func PreRunEFunc(config *Config) func(*cobra.Command, []string) error { //nolint v.SetConfigType("yml") } - v.AddConfigPath(args[0]) // first look at module root - v.AddConfigPath(".") // then current directory - v.AddConfigPath("$HOME/.tfdocs.d") // and finally $HOME/.tfdocs.d/ + v.AddConfigPath(args[0]) // first look at module root + v.AddConfigPath(args[0] + "/.config") // then .config/ folder at module root + v.AddConfigPath(".") // then current directory + v.AddConfigPath(".config") // then .config/ folder at current directory + v.AddConfigPath("$HOME/.tfdocs.d") // and finally $HOME/.tfdocs.d/ if err := v.ReadInConfig(); err != nil { var perr *os.PathError