Skip to content

Commit 1a3dce2

Browse files
remilapeyredetro
authored andcommitted
Add option to ignore deprecated resources and data-sources
1 parent 091ffc6 commit 1a3dce2

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

internal/cmd/generate.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ import (
1111
type generateCmd struct {
1212
commonCmd
1313

14-
flagLegacySidebar bool
14+
flagLegacySidebar bool
15+
flagIgnoreDeprecated bool
1516

1617
flagProviderName string
1718
flagRenderedProviderName string
@@ -75,6 +76,7 @@ func (cmd *generateCmd) Flags() *flag.FlagSet {
7576
fs.StringVar(&cmd.flagWebsiteTmpDir, "website-temp-dir", "", "temporary directory (used during generation)")
7677
fs.StringVar(&cmd.flagWebsiteSourceDir, "website-source-dir", "templates", "templates directory")
7778
fs.StringVar(&cmd.tfVersion, "tf-version", "", "terraform binary version to download")
79+
fs.BoolVar(&cmd.flagIgnoreDeprecated, "ignore-deprecated", false, "don't generate documentation for deprecated resources and data-sources")
7880
return fs
7981
}
8082

@@ -100,6 +102,7 @@ func (cmd *generateCmd) runInternal() error {
100102
cmd.flagWebsiteTmpDir,
101103
cmd.flagWebsiteSourceDir,
102104
cmd.tfVersion,
105+
cmd.flagIgnoreDeprecated,
103106
)
104107
if err != nil {
105108
return fmt.Errorf("unable to generate website: %w", err)

internal/provider/generate.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ var (
6464
)
6565

6666
type generator struct {
67-
legacySidebar bool
68-
tfVersion string
67+
ignoreDeprecated bool
68+
legacySidebar bool
69+
tfVersion string
6970

7071
providerName string
7172
renderedProviderName string
@@ -85,10 +86,11 @@ func (g *generator) warnf(format string, a ...interface{}) {
8586
g.ui.Warn(fmt.Sprintf(format, a...))
8687
}
8788

88-
func Generate(ui cli.Ui, legacySidebar bool, providerName, renderedProviderName, renderedWebsiteDir, examplesDir, websiteTmpDir, websiteSourceDir, tfVersion string) error {
89+
func Generate(ui cli.Ui, legacySidebar bool, providerName, renderedProviderName, renderedWebsiteDir, examplesDir, websiteTmpDir, websiteSourceDir, tfVersion string, ignoreDeprecated bool) error {
8990
g := &generator{
90-
legacySidebar: legacySidebar,
91-
tfVersion: tfVersion,
91+
ignoreDeprecated: ignoreDeprecated,
92+
legacySidebar: legacySidebar,
93+
tfVersion: tfVersion,
9294

9395
providerName: providerName,
9496
renderedProviderName: renderedProviderName,
@@ -319,6 +321,10 @@ func (g *generator) renderMissingProviderDoc(providerName string, schema *tfjson
319321
func (g *generator) renderMissingDocs(providerName string, providerSchema *tfjson.ProviderSchema) error {
320322
g.infof("generating missing resource content")
321323
for name, schema := range providerSchema.ResourceSchemas {
324+
if g.ignoreDeprecated && schema.Block.Deprecated {
325+
continue
326+
}
327+
322328
err := g.renderMissingResourceDoc(providerName, name, "Resource", schema,
323329
websiteResourceFileTemplate,
324330
websiteResourceFallbackFileTemplate,
@@ -332,6 +338,10 @@ func (g *generator) renderMissingDocs(providerName string, providerSchema *tfjso
332338

333339
g.infof("generating missing data source content")
334340
for name, schema := range providerSchema.DataSourceSchemas {
341+
if g.ignoreDeprecated && schema.Block.Deprecated {
342+
continue
343+
}
344+
335345
err := g.renderMissingResourceDoc(providerName, name, "Data Source", schema,
336346
websiteDataSourceFileTemplate,
337347
websiteDataSourceFallbackFileTemplate,

0 commit comments

Comments
 (0)