mirror of
https://github.com/terraform-docs/terraform-docs.git
synced 2026-03-27 12:58:35 +07:00
Make main module doc optional when in recursive generation
Signed-off-by: Blake Gong <blakegong@gmail.com>
This commit is contained in:
committed by
Khosrow Moossavi
parent
e9192750e0
commit
59eb90fc86
@@ -180,6 +180,7 @@ footer-from: ""
|
||||
recursive:
|
||||
enabled: false
|
||||
path: modules
|
||||
include-main: true
|
||||
|
||||
sections:
|
||||
hide: []
|
||||
|
||||
@@ -62,6 +62,7 @@ func NewCommand() *cobra.Command {
|
||||
cmd.PersistentFlags().StringVarP(&config.File, "config", "c", ".terraform-docs.yml", "config file name")
|
||||
cmd.PersistentFlags().BoolVar(&config.Recursive.Enabled, "recursive", false, "update submodules recursively (default false)")
|
||||
cmd.PersistentFlags().StringVar(&config.Recursive.Path, "recursive-path", "modules", "submodules path to recursively update")
|
||||
cmd.PersistentFlags().BoolVar(&config.Recursive.IncludeMain, "recursive-include-main", true, "include the main module (default true)")
|
||||
|
||||
cmd.PersistentFlags().StringSliceVar(&config.Sections.Show, "show", []string{}, "show section ["+print.AllSections+"]")
|
||||
cmd.PersistentFlags().StringSliceVar(&config.Sections.Hide, "hide", []string{}, "hide section ["+print.AllSections+"]")
|
||||
|
||||
@@ -22,6 +22,8 @@ set.
|
||||
Path to find submodules can be configured with `--recursive-path` (defaults to
|
||||
`modules`).
|
||||
|
||||
The main module document is generated by default, which can be configured with `--recursive-include-main`. Should the main module document be excluded from document generation, use `--recursive-include-main=false`.
|
||||
|
||||
Each submodule can also have their own `.terraform-docs.yml` config file, to
|
||||
override configuration from root module.
|
||||
|
||||
|
||||
@@ -79,6 +79,7 @@ footer-from: ""
|
||||
recursive:
|
||||
enabled: false
|
||||
path: modules
|
||||
include-main: true
|
||||
|
||||
sections:
|
||||
hide: []
|
||||
|
||||
@@ -32,6 +32,7 @@ Available options with their default values.
|
||||
recursive:
|
||||
enabled: false
|
||||
path: modules
|
||||
include-main: true
|
||||
```
|
||||
|
||||
## Examples
|
||||
@@ -50,3 +51,12 @@ recursive:
|
||||
enabled: true
|
||||
path: submodules-folder
|
||||
```
|
||||
|
||||
Skip the main module document, and only generate documents for submodules.
|
||||
|
||||
```yaml
|
||||
recursive:
|
||||
enabled: true
|
||||
path: submodules-folder
|
||||
include-main: false
|
||||
```
|
||||
|
||||
@@ -94,9 +94,11 @@ type module struct {
|
||||
// RunEFunc is the 'cobra.Command#RunE' function for 'formatter' commands. It attempts
|
||||
// to discover submodules, on `--recursive` flag, and generates the content for them
|
||||
// as well as the root module.
|
||||
func (r *Runtime) RunEFunc(cmd *cobra.Command, args []string) error {
|
||||
modules := []module{
|
||||
{rootDir: r.rootDir, config: r.config},
|
||||
func (r *Runtime) RunEFunc(cmd *cobra.Command, args []string) error { //nolint:gocyclo
|
||||
modules := []module{}
|
||||
|
||||
if r.config.Recursive.IncludeMain {
|
||||
modules = append(modules, module{r.rootDir, r.config})
|
||||
}
|
||||
|
||||
// Generating content recursively is only allowed when `config.Output.File`
|
||||
|
||||
@@ -73,14 +73,16 @@ func DefaultConfig() *Config {
|
||||
}
|
||||
|
||||
type recursive struct {
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Path string `mapstructure:"path"`
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Path string `mapstructure:"path"`
|
||||
IncludeMain bool `mapstructure:"include-main"`
|
||||
}
|
||||
|
||||
func defaultRecursive() recursive {
|
||||
return recursive{
|
||||
Enabled: false,
|
||||
Path: "modules",
|
||||
Enabled: false,
|
||||
Path: "modules",
|
||||
IncludeMain: true,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user